[Mlir-commits] [llvm] [mlir] [AMDGPU][Verifier] Check address space of `alloca` instruction (PR #135820)

Nikita Popov llvmlistbot at llvm.org
Fri Apr 25 07:58:09 PDT 2025


================
@@ -4395,6 +4395,11 @@ void Verifier::visitAllocaInst(AllocaInst &AI) {
     verifySwiftErrorValue(&AI);
   }
 
+  if (TT.isAMDGPU()) {
+    Check(AI.getAddressSpace() == AMDGPUAS::PRIVATE_ADDRESS,
+          "alloca on amdgpu must be in addrspace(5)", &AI);
----------------
nikic wrote:

Might be better to check it against the alloca addrspace from the data layout instead of hardcoding 5?

My thinking is that this way we could extend this check to most other targets as well (mainly excluding wasm and any other that may be using multiple alloca address spaces).

(Another more involved alternative would be to allow specifying multiple alloca address spaces in DL, and making the first the preferred one. Then this could be a target-independent check.)

https://github.com/llvm/llvm-project/pull/135820


More information about the Mlir-commits mailing list