[llvm] [AMDGPU] Support alloca in AS0 (PR #136584)
Fabian Ritter via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 22 00:38:22 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.getAllocatedType(), DL.getAllocaAddrSpace(), I.getArraySize());
+ NewAI->takeName(&I);
+ NewAI->copyMetadata(I);
----------------
ritter-x2a wrote:
Should we also copy the alignment from the original alloca?
https://github.com/llvm/llvm-project/pull/136584
More information about the llvm-commits
mailing list