[PATCH] D156409: [AMDGPU] More verifier checks for llvm.amdgcn.cs.chain

Diana Picus via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 27 03:12:12 PDT 2023


rovka created this revision.
Herald added subscribers: kerbowa, hiraditya, tpr, dstuttard, yaxunl, jvesely, kzhuravl.
Herald added a project: All.
rovka requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

Check that the SGPR arguments have the `inreg` attribute and the VGPR
arguments don't.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156409

Files:
  llvm/lib/IR/Verifier.cpp
  llvm/test/Verifier/AMDGPU/intrinsic-amdgpu-cs-chain.ll


Index: llvm/test/Verifier/AMDGPU/intrinsic-amdgpu-cs-chain.ll
===================================================================
--- llvm/test/Verifier/AMDGPU/intrinsic-amdgpu-cs-chain.ll
+++ llvm/test/Verifier/AMDGPU/intrinsic-amdgpu-cs-chain.ll
@@ -10,6 +10,20 @@
   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
Index: llvm/lib/IR/Verifier.cpp
===================================================================
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -6062,6 +6062,11 @@
                   &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:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156409.544677.patch
Type: text/x-patch
Size: 1843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230727/47171de2/attachment.bin>


More information about the llvm-commits mailing list