[PATCH] D132931: [Attributor] Simplify offset calculation for a constant GEP
Sameer Sahasrabuddhe via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 31 05:03:08 PDT 2022
sameerds updated this revision to Diff 456931.
sameerds added a comment.
Simpler check for constant offset. We don't really care if the indices are constant.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132931/new/
https://reviews.llvm.org/D132931
Files:
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Index: llvm/lib/Transforms/IPO/AttributorAttributes.cpp
===================================================================
--- llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -1280,26 +1280,15 @@
UsrOI = PtrOI;
// TODO: Use range information.
+ APInt GEPOffset(DL.getIndexTypeSizeInBits(GEP->getType()), 0);
if (PtrOI.Offset == OffsetAndSize::Unknown ||
- !GEP->hasAllConstantIndices()) {
+ !GEP->accumulateConstantOffset(DL, GEPOffset)) {
UsrOI.Offset = OffsetAndSize::Unknown;
Follow = true;
return true;
}
- SmallVector<Value *, 8> Indices;
- for (Use &Idx : GEP->indices()) {
- if (auto *CIdx = dyn_cast<ConstantInt>(Idx)) {
- Indices.push_back(CIdx);
- continue;
- }
-
- LLVM_DEBUG(dbgs() << "[AAPointerInfo] Non constant GEP index " << *GEP
- << " : " << *Idx << "\n");
- return false;
- }
- UsrOI.Offset = PtrOI.Offset + DL.getIndexedOffsetInType(
- GEP->getSourceElementType(), Indices);
+ UsrOI.Offset = PtrOI.Offset + GEPOffset.getZExtValue();
Follow = true;
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132931.456931.patch
Type: text/x-patch
Size: 1330 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220831/b5bda58e/attachment.bin>
More information about the llvm-commits
mailing list