return false;
}
-// FIXME: switch to non-permissive DomTreeUpdater::applyUpdates().
bool SimplifyCFGOpt::simplifyUnreachable(UnreachableInst *UI) {
BasicBlock *BB = UI->getParent();
std::vector<DominatorTree::UpdateType> Updates;
- SmallVector<BasicBlock *, 8> Preds(predecessors(BB));
+ SmallSetVector<BasicBlock *, 8> Preds(pred_begin(BB), pred_end(BB));
for (unsigned i = 0, e = Preds.size(); i != e; ++i) {
auto *Predecessor = Preds[i];
Instruction *TI = Predecessor->getTerminator();
e = SU->case_end();
Changed = true;
}
- Updates.push_back({DominatorTree::Delete, Predecessor, BB});
+ // Note that the default destination can't be removed!
+ if (SI->getDefaultDest() != BB)
+ Updates.push_back({DominatorTree::Delete, Predecessor, BB});
} else if (auto *II = dyn_cast<InvokeInst>(TI)) {
if (II->getUnwindDest() == BB) {
if (DTU)
}
if (DTU)
- DTU->applyUpdatesPermissive(Updates);
+ DTU->applyUpdates(Updates);
// If this block is now dead, remove it.
if (pred_empty(BB) && BB != &BB->getParent()->getEntryBlock()) {