[llvm] [AMDGPU] Support alloca in AS0 (PR #136584)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 21 10:32:37 PDT 2025
================
@@ -2355,6 +2358,23 @@ bool AMDGPUCodeGenPrepareImpl::visitSqrt(IntrinsicInst &Sqrt) {
return true;
}
+// Rewrite alloca with AS0 to alloca with AS5 followed by a addrspace cast.
+bool AMDGPUCodeGenPrepareImpl::visitAllocaInst(AllocaInst &I) {
+ if (I.getAddressSpace() == DL.getAllocaAddrSpace())
+ return false;
+ assert(I.getAddressSpace() == 0 && "An alloca can't be in random AS");
+ IRBuilder<> Builder(&I);
+ AllocaInst *NewAI = Builder.CreateAlloca(I.getType(), DL.getAllocaAddrSpace(),
----------------
shiltian wrote:
Oh I used a wrong type here. Will update it .
https://github.com/llvm/llvm-project/pull/136584
More information about the llvm-commits
mailing list