[PATCH] D81256: Upgrade TypePromotionTransaction to be able to report changes in CodeGenPrepare
serge via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 7 01:57:12 PDT 2020
serge-sans-paille updated this revision to Diff 275946.
serge-sans-paille marked 2 inline comments as done.
serge-sans-paille added a comment.
Stick to original API for easier maintenance.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81256/new/
https://reviews.llvm.org/D81256
Files:
llvm/lib/CodeGen/CodeGenPrepare.cpp
Index: llvm/lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -2822,8 +2822,9 @@
TypePromotionTransaction(SetOfInstrs &RemovedInsts)
: RemovedInsts(RemovedInsts) {}
- /// Advocate every changes made in that transaction.
- void commit();
+ /// Advocate every changes made in that transaction. Return true if any change
+ /// happen.
+ bool commit();
/// Undo all the changes made after the given point.
void rollback(ConstRestorationPt Point);
@@ -2929,11 +2930,13 @@
return !Actions.empty() ? Actions.back().get() : nullptr;
}
-void TypePromotionTransaction::commit() {
+bool TypePromotionTransaction::commit() {
for (CommitPt It = Actions.begin(), EndIt = Actions.end(); It != EndIt;
++It)
(*It)->commit();
+ bool Modified = !Actions.empty();
Actions.clear();
+ return Modified;
}
void TypePromotionTransaction::rollback(
@@ -4959,7 +4962,7 @@
TPT.rollback(LastKnownGood);
return false;
}
- TPT.commit();
+ bool Modified = TPT.commit();
// Get the combined AddrMode (or the only AddrMode, if we only had one).
ExtAddrMode AddrMode = AddrModes.getAddrMode();
@@ -4973,7 +4976,7 @@
})) {
LLVM_DEBUG(dbgs() << "CGP: Found local addrmode: " << AddrMode
<< "\n");
- return false;
+ return Modified;
}
// Insert this computation right after this user. Since our caller is
@@ -5014,7 +5017,7 @@
// We can't add more than one pointer together, nor can we scale a
// pointer (both of which seem meaningless).
if (ResultPtr || AddrMode.Scale != 1)
- return false;
+ return Modified;
ResultPtr = AddrMode.ScaledReg;
AddrMode.Scale = 0;
@@ -5031,12 +5034,12 @@
Type *ScaledRegTy = AddrMode.ScaledReg->getType();
if (cast<IntegerType>(IntPtrTy)->getBitWidth() >
cast<IntegerType>(ScaledRegTy)->getBitWidth())
- return false;
+ return Modified;
}
if (AddrMode.BaseGV) {
if (ResultPtr)
- return false;
+ return Modified;
ResultPtr = AddrMode.BaseGV;
}
@@ -5060,7 +5063,7 @@
!AddrMode.BaseReg && !AddrMode.Scale && !AddrMode.BaseOffs) {
SunkAddr = Constant::getNullValue(Addr->getType());
} else if (!ResultPtr) {
- return false;
+ return Modified;
} else {
Type *I8PtrTy =
Builder.getInt8PtrTy(Addr->getType()->getPointerAddressSpace());
@@ -5145,7 +5148,7 @@
(ScalePtrTy && DL->isNonIntegralPointerType(ScalePtrTy)) ||
(AddrMode.BaseGV &&
DL->isNonIntegralPointerType(AddrMode.BaseGV->getType())))
- return false;
+ return Modified;
LLVM_DEBUG(dbgs() << "CGP: SINKING nonlocal addrmode: " << AddrMode
<< " for " << *MemoryInst << "\n");
@@ -5185,7 +5188,7 @@
Instruction *I = dyn_cast_or_null<Instruction>(Result);
if (I && (Result != AddrMode.BaseReg))
I->eraseFromParent();
- return false;
+ return Modified;
}
if (AddrMode.Scale != 1)
V = Builder.CreateMul(V, ConstantInt::get(IntPtrTy, AddrMode.Scale),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81256.275946.patch
Type: text/x-patch
Size: 3297 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200707/8baf095e/attachment.bin>
More information about the llvm-commits
mailing list