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

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 25 13:04:56 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);
----------------
shiltian wrote:

Do we want it just to be for verification only? The point @arsenm made was that DL doesn't assert anything. If we can make it assert, it is gonna be more useful? Also, if we enforce alloca to be in specific AS(s), it is a form of assertion right? Therefore, we **can** use it in the middle end for optimization. Of course if a target accepts multiple ASs for alloca, we can't assert it must be in exact one, but for those only have one, we can assert.

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


More information about the llvm-commits mailing list