mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[SimplifyCFG] simplifyIndirectBr(): switch to non-permissive DomTree updates
... which requires not deleting an edge that just got deleted.
This commit is contained in:
parent
3715f53732
commit
435c195959
@ -6218,19 +6218,18 @@ bool SimplifyCFGOpt::simplifySwitch(SwitchInst *SI, IRBuilder<> &Builder) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME: switch to non-permissive DomTreeUpdater::applyUpdates().
|
||||
bool SimplifyCFGOpt::simplifyIndirectBr(IndirectBrInst *IBI) {
|
||||
BasicBlock *BB = IBI->getParent();
|
||||
bool Changed = false;
|
||||
|
||||
// Eliminate redundant destinations.
|
||||
std::vector<DominatorTree::UpdateType> Updates;
|
||||
SmallPtrSet<Value *, 8> Succs;
|
||||
SmallSetVector<BasicBlock *, 8> RemovedSuccs;
|
||||
for (unsigned i = 0, e = IBI->getNumDestinations(); i != e; ++i) {
|
||||
BasicBlock *Dest = IBI->getDestination(i);
|
||||
if (!Dest->hasAddressTaken() || !Succs.insert(Dest).second) {
|
||||
if (!Dest->hasAddressTaken())
|
||||
Updates.push_back({DominatorTree::Delete, BB, Dest});
|
||||
RemovedSuccs.insert(Dest);
|
||||
Dest->removePredecessor(BB);
|
||||
IBI->removeDestination(i);
|
||||
--i;
|
||||
@ -6239,9 +6238,13 @@ bool SimplifyCFGOpt::simplifyIndirectBr(IndirectBrInst *IBI) {
|
||||
}
|
||||
}
|
||||
|
||||
if (DTU)
|
||||
DTU->applyUpdatesPermissive(Updates);
|
||||
Updates.clear();
|
||||
if (DTU) {
|
||||
std::vector<DominatorTree::UpdateType> Updates;
|
||||
Updates.reserve(RemovedSuccs.size());
|
||||
for (auto *RemovedSucc : RemovedSuccs)
|
||||
Updates.push_back({DominatorTree::Delete, BB, RemovedSucc});
|
||||
DTU->applyUpdates(Updates);
|
||||
}
|
||||
|
||||
if (IBI->getNumDestinations() == 0) {
|
||||
// If the indirectbr has no successors, change it to unreachable.
|
||||
|
Loading…
Reference in New Issue
Block a user