forked from OSchip/llvm-project
[PM] Replace the Pass argument in MergeBasicBlockIntoOnlyPred with
a DominatorTree argument as that is the analysis that it wants to update. This removes the last non-loop utility function in Utils/ which accepts a raw Pass argument. llvm-svn: 226537
This commit is contained in:
parent
408f5a25fa
commit
10f28f26fd
|
@ -31,7 +31,6 @@ class DbgDeclareInst;
|
||||||
class StoreInst;
|
class StoreInst;
|
||||||
class LoadInst;
|
class LoadInst;
|
||||||
class Value;
|
class Value;
|
||||||
class Pass;
|
|
||||||
class PHINode;
|
class PHINode;
|
||||||
class AllocaInst;
|
class AllocaInst;
|
||||||
class AssumptionCache;
|
class AssumptionCache;
|
||||||
|
@ -115,7 +114,7 @@ void RemovePredecessorAndSimplify(BasicBlock *BB, BasicBlock *Pred,
|
||||||
/// between them, moving the instructions in the predecessor into BB. This
|
/// between them, moving the instructions in the predecessor into BB. This
|
||||||
/// deletes the predecessor block.
|
/// deletes the predecessor block.
|
||||||
///
|
///
|
||||||
void MergeBasicBlockIntoOnlyPred(BasicBlock *BB, Pass *P = nullptr);
|
void MergeBasicBlockIntoOnlyPred(BasicBlock *BB, DominatorTree *DT = nullptr);
|
||||||
|
|
||||||
/// TryToSimplifyUncondBranchFromEmptyBlock - BB is known to contain an
|
/// TryToSimplifyUncondBranchFromEmptyBlock - BB is known to contain an
|
||||||
/// unconditional branch, and contains no instructions other than PHI nodes,
|
/// unconditional branch, and contains no instructions other than PHI nodes,
|
||||||
|
|
|
@ -342,7 +342,7 @@ bool CodeGenPrepare::EliminateFallThrough(Function &F) {
|
||||||
// Remember if SinglePred was the entry block of the function.
|
// Remember if SinglePred was the entry block of the function.
|
||||||
// If so, we will need to move BB back to the entry position.
|
// If so, we will need to move BB back to the entry position.
|
||||||
bool isEntry = SinglePred == &SinglePred->getParent()->getEntryBlock();
|
bool isEntry = SinglePred == &SinglePred->getParent()->getEntryBlock();
|
||||||
MergeBasicBlockIntoOnlyPred(BB, this);
|
MergeBasicBlockIntoOnlyPred(BB, DT);
|
||||||
|
|
||||||
if (isEntry && BB != &BB->getParent()->getEntryBlock())
|
if (isEntry && BB != &BB->getParent()->getEntryBlock())
|
||||||
BB->moveBefore(&BB->getParent()->getEntryBlock());
|
BB->moveBefore(&BB->getParent()->getEntryBlock());
|
||||||
|
@ -482,7 +482,7 @@ void CodeGenPrepare::EliminateMostlyEmptyBlock(BasicBlock *BB) {
|
||||||
// Remember if SinglePred was the entry block of the function. If so, we
|
// Remember if SinglePred was the entry block of the function. If so, we
|
||||||
// will need to move BB back to the entry position.
|
// will need to move BB back to the entry position.
|
||||||
bool isEntry = SinglePred == &SinglePred->getParent()->getEntryBlock();
|
bool isEntry = SinglePred == &SinglePred->getParent()->getEntryBlock();
|
||||||
MergeBasicBlockIntoOnlyPred(DestBB, this);
|
MergeBasicBlockIntoOnlyPred(DestBB, DT);
|
||||||
|
|
||||||
if (isEntry && BB != &BB->getParent()->getEntryBlock())
|
if (isEntry && BB != &BB->getParent()->getEntryBlock())
|
||||||
BB->moveBefore(&BB->getParent()->getEntryBlock());
|
BB->moveBefore(&BB->getParent()->getEntryBlock());
|
||||||
|
|
|
@ -489,7 +489,7 @@ void llvm::RemovePredecessorAndSimplify(BasicBlock *BB, BasicBlock *Pred,
|
||||||
/// between them, moving the instructions in the predecessor into DestBB and
|
/// between them, moving the instructions in the predecessor into DestBB and
|
||||||
/// deleting the predecessor block.
|
/// deleting the predecessor block.
|
||||||
///
|
///
|
||||||
void llvm::MergeBasicBlockIntoOnlyPred(BasicBlock *DestBB, Pass *P) {
|
void llvm::MergeBasicBlockIntoOnlyPred(BasicBlock *DestBB, DominatorTree *DT) {
|
||||||
// If BB has single-entry PHI nodes, fold them.
|
// If BB has single-entry PHI nodes, fold them.
|
||||||
while (PHINode *PN = dyn_cast<PHINode>(DestBB->begin())) {
|
while (PHINode *PN = dyn_cast<PHINode>(DestBB->begin())) {
|
||||||
Value *NewVal = PN->getIncomingValue(0);
|
Value *NewVal = PN->getIncomingValue(0);
|
||||||
|
@ -525,14 +525,10 @@ void llvm::MergeBasicBlockIntoOnlyPred(BasicBlock *DestBB, Pass *P) {
|
||||||
if (PredBB == &DestBB->getParent()->getEntryBlock())
|
if (PredBB == &DestBB->getParent()->getEntryBlock())
|
||||||
DestBB->moveAfter(PredBB);
|
DestBB->moveAfter(PredBB);
|
||||||
|
|
||||||
if (P) {
|
if (DT) {
|
||||||
if (DominatorTreeWrapperPass *DTWP =
|
BasicBlock *PredBBIDom = DT->getNode(PredBB)->getIDom()->getBlock();
|
||||||
P->getAnalysisIfAvailable<DominatorTreeWrapperPass>()) {
|
DT->changeImmediateDominator(DestBB, PredBBIDom);
|
||||||
DominatorTree &DT = DTWP->getDomTree();
|
DT->eraseNode(PredBB);
|
||||||
BasicBlock *PredBBIDom = DT.getNode(PredBB)->getIDom()->getBlock();
|
|
||||||
DT.changeImmediateDominator(DestBB, PredBBIDom);
|
|
||||||
DT.eraseNode(PredBB);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Nuke BB.
|
// Nuke BB.
|
||||||
PredBB->eraseFromParent();
|
PredBB->eraseFromParent();
|
||||||
|
|
Loading…
Reference in New Issue