Skip to content

Commit

Permalink
[AMDGPU] More verifier checks for llvm.amdgcn.cs.chain
Browse files Browse the repository at this point in the history
Check that the SGPR arguments have the `inreg` attribute and the VGPR
arguments don't.

Differential Revision: https://reviews.llvm.org/D156409
  • Loading branch information
rovka committed Aug 17, 2023
1 parent 3568976 commit 5a8ecd6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions llvm/lib/IR/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5919,6 +5919,11 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
&Call);
break;
}

Check(Call.paramHasAttr(2, Attribute::InReg),
"SGPR arguments must have the `inreg` attribute", &Call);
Check(!Call.paramHasAttr(3, Attribute::InReg),
"VGPR arguments must not have the `inreg` attribute", &Call);
break;
}
case Intrinsic::experimental_convergence_entry:
Expand Down
14 changes: 14 additions & 0 deletions llvm/test/Verifier/AMDGPU/intrinsic-amdgpu-cs-chain.ll
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ define amdgpu_cs_chain void @bad_flags(ptr %fn, i32 %exec, <4 x i32> inreg %sgpr
unreachable
}

define amdgpu_cs_chain void @bad_vgpr_args(ptr %fn, i32 %exec, <4 x i32> inreg %sgpr, { ptr, <3 x i32> } inreg %vgpr) {
; CHECK: VGPR arguments must not have the `inreg` attribute
; CHECK-NEXT: @llvm.amdgcn.cs.chain
call void(ptr, i32, <4 x i32>, { ptr, <3 x i32> }, i32, ...) @llvm.amdgcn.cs.chain(ptr %fn, i32 %exec, <4 x i32> inreg %sgpr, { ptr, <3 x i32> } inreg %vgpr, i32 0)
unreachable
}

define amdgpu_cs_chain void @bad_sgpr_args(ptr %fn, i32 %exec, <4 x i32> %sgpr, { ptr, <3 x i32> } %vgpr) {
; CHECK: SGPR arguments must have the `inreg` attribute
; CHECK-NEXT: @llvm.amdgcn.cs.chain
call void(ptr, i32, <4 x i32>, { ptr, <3 x i32> }, i32, ...) @llvm.amdgcn.cs.chain(ptr %fn, i32 %exec, <4 x i32> %sgpr, { ptr, <3 x i32> } %vgpr, i32 0)
unreachable
}

define amdgpu_cs_chain void @bad_exec(ptr %fn, i32 %exec, <4 x i32> inreg %sgpr, { ptr, <3 x i32> } %vgpr, i32 %flags) {
; CHECK: Intrinsic called with incompatible signature
; CHECK-NEXT: @llvm.amdgcn.cs.chain
Expand Down

0 comments on commit 5a8ecd6

Please sign in to comment.