[llvm] [AMDGPU] PromoteAlloca: reject known out-of-bounds index (PR #139700)
Robert Imschweiler via llvm-commits
llvm-commits at lists.llvm.org
Tue May 13 07:37:59 PDT 2025
================
@@ -920,6 +919,12 @@ bool AMDGPUPromoteAllocaImpl::tryPromoteAllocaToVector(AllocaInst &Alloca) {
Value *Index = GEPToVectorIndex(GEP, &Alloca, VecEltTy, *DL, NewGEPInsts);
if (!Index)
return RejectUser(Inst, "cannot compute vector index for GEP");
+ // Alternatively, if there is a constant index for which we already know
+ // that it will be out-of-bounds, we also don't want to promote this
+ // alloca to vector.
+ if (ConstantInt *I = dyn_cast<ConstantInt>(Index);
+ I && I->getZExtValue() >= Alloca.getAllocationSize(*DL))
+ return RejectUser(Inst, "GEP constant index out-of-bounds");
----------------
ro-i wrote:
I see, I think I now get what you mean
https://github.com/llvm/llvm-project/pull/139700
More information about the llvm-commits
mailing list