[llvm] [AMDGPU] PromoteAlloca: reject known out-of-bounds index (PR #139700)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue May 13 06:28:03 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))
----------------
arsenm wrote:

Mostly you just need to avoid crashing in the compiler, and you should be able to ignore the index. It was UB and you are at most downgrading it to a poison value 

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


More information about the llvm-commits mailing list