[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 06:23:06 PDT 2025
================
@@ -438,7 +438,8 @@ static Value *GEPToVectorIndex(GetElementPtrInst *GEP, AllocaInst *Alloca,
SmallMapVector<Value *, APInt, 4> VarOffsets;
APInt ConstOffset(BW, 0);
if (GEP->getPointerOperand()->stripPointerCasts() != Alloca ||
- !GEP->collectOffset(DL, BW, VarOffsets, ConstOffset))
+ !GEP->collectOffset(DL, BW, VarOffsets, ConstOffset) ||
+ ConstOffset.getZExtValue() >= Alloca->getAllocationSize(DL))
----------------
ro-i wrote:
True, I separated it.
It would also be possible to implement the check specifically here (`SrcBegin`):
https://github.com/llvm/llvm-project/blob/84c1564d1825880d463d9f85153812f1f6805289/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp#L663-L675
but that wouldn't cover as many cases and I think that doesn't hurt (?)
https://github.com/llvm/llvm-project/pull/139700
More information about the llvm-commits
mailing list