Skip to content

Commit

Permalink
Merged master:edc7da24057 into amd-gfx:5925a948df2
Browse files Browse the repository at this point in the history
Local branch amd-gfx 5925a94 Merged master:f54d0e36be6 into amd-gfx:5596bea4e4c
Remote branch master edc7da2 Upgrade TypePromotionTransaction to be able to report changes in CodeGenPrepare
  • Loading branch information
Sw authored and Sw committed Jul 8, 2020
2 parents 5925a94 + edc7da2 commit f8416c3
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions llvm/lib/CodeGen/CodeGenPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2822,8 +2822,9 @@ class TypePromotionTransaction {
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);
Expand Down Expand Up @@ -2929,11 +2930,13 @@ TypePromotionTransaction::getRestorationPoint() const {
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(
Expand Down Expand Up @@ -4959,7 +4962,7 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
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();
Expand All @@ -4973,7 +4976,7 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
})) {
LLVM_DEBUG(dbgs() << "CGP: Found local addrmode: " << AddrMode
<< "\n");
return false;
return Modified;
}

// Insert this computation right after this user. Since our caller is
Expand Down Expand Up @@ -5014,7 +5017,7 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
// 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;
Expand All @@ -5031,12 +5034,12 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
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;
}
Expand All @@ -5060,7 +5063,7 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
!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());
Expand Down Expand Up @@ -5145,7 +5148,7 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
(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");
Expand Down Expand Up @@ -5185,7 +5188,7 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
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),
Expand Down

0 comments on commit f8416c3

Please sign in to comment.