[llvm] [AMDGPU] Update PromoteAlloca to handle GEPs with variable offset. (PR #122342)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 20 08:02:46 PST 2025
================
@@ -385,16 +385,21 @@ static bool isSupportedMemset(MemSetInst *I, AllocaInst *AI,
match(I->getOperand(2), m_SpecificInt(Size)) && !I->isVolatile();
}
-static Value *
-calculateVectorIndex(Value *Ptr,
- const std::map<GetElementPtrInst *, Value *> &GEPIdx) {
+static Value *calculateVectorIndex(
+ Value *Ptr, const std::map<GetElementPtrInst *, WeakTrackingVH> &GEPIdx) {
auto *GEP = dyn_cast<GetElementPtrInst>(Ptr->stripPointerCasts());
if (!GEP)
return ConstantInt::getNullValue(Type::getInt32Ty(Ptr->getContext()));
auto I = GEPIdx.find(GEP);
assert(I != GEPIdx.end() && "Must have entry for GEP!");
- return I->second;
+
+ if (Value *IndexValue = I->second)
+ return IndexValue;
+
+ llvm_unreachable(
+ "Index value is not present in Cached GEPs! This indicates a "
+ "bug in the pass that populates GEPIdx.");
----------------
arsenm wrote:
```suggestion
Value *IndexValue = I->second;
assert(IndexValue && "index value missing from GEP index map");
return IndexValue;
```
https://github.com/llvm/llvm-project/pull/122342
More information about the llvm-commits
mailing list