[PATCH] D132931: [Attributor] Simplify offset calculation for a constant GEP
Sameer Sahasrabuddhe via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 2 11:24:42 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG46b293cb3f8d: [Attributor] Simplify offset calculation for a constant GEP (authored by sameerds).
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.457650.patch
Type: text/x-patch
Size: 1330 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220902/2231ea31/attachment.bin>
More information about the llvm-commits
mailing list