forked from OSchip/llvm-project
[SimplifyCFG] SimplifyEqualityComparisonWithOnlyPredecessor(): switch to non-permissive DomTree updates
... which requires not deleting an edge that just got deleted.
This commit is contained in:
parent
a8604e3d5b
commit
110b3d7855
|
@ -872,7 +872,6 @@ static void setBranchWeights(Instruction *I, uint32_t TrueWeight,
|
|||
/// also a value comparison with the same value, and if that comparison
|
||||
/// determines the outcome of this comparison. If so, simplify TI. This does a
|
||||
/// very limited form of jump threading.
|
||||
// FIXME: switch to non-permissive DomTreeUpdater::applyUpdates().
|
||||
bool SimplifyCFGOpt::SimplifyEqualityComparisonWithOnlyPredecessor(
|
||||
Instruction *TI, BasicBlock *Pred, IRBuilder<> &Builder) {
|
||||
Value *PredVal = isValueEqualityComparison(Pred->getTerminator());
|
||||
|
@ -988,14 +987,14 @@ bool SimplifyCFGOpt::SimplifyEqualityComparisonWithOnlyPredecessor(
|
|||
if (!TheRealDest)
|
||||
TheRealDest = ThisDef;
|
||||
|
||||
SmallVector<DominatorTree::UpdateType, 2> Updates;
|
||||
SmallSetVector<BasicBlock *, 2> RemovedSuccs;
|
||||
|
||||
// Remove PHI node entries for dead edges.
|
||||
BasicBlock *CheckEdge = TheRealDest;
|
||||
for (BasicBlock *Succ : successors(TIBB))
|
||||
if (Succ != CheckEdge) {
|
||||
RemovedSuccs.insert(Succ);
|
||||
Succ->removePredecessor(TIBB);
|
||||
Updates.push_back({DominatorTree::Delete, TIBB, Succ});
|
||||
} else
|
||||
CheckEdge = nullptr;
|
||||
|
||||
|
@ -1008,8 +1007,13 @@ bool SimplifyCFGOpt::SimplifyEqualityComparisonWithOnlyPredecessor(
|
|||
<< "\n");
|
||||
|
||||
EraseTerminatorAndDCECond(TI);
|
||||
if (DTU)
|
||||
DTU->applyUpdatesPermissive(Updates);
|
||||
if (DTU) {
|
||||
SmallVector<DominatorTree::UpdateType, 2> Updates;
|
||||
Updates.reserve(RemovedSuccs.size());
|
||||
for (auto *RemovedSucc : RemovedSuccs)
|
||||
Updates.push_back({DominatorTree::Delete, TIBB, RemovedSucc});
|
||||
DTU->applyUpdates(Updates);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue