forked from OSchip/llvm-project
[SimplifyCFG] markAliveBlocks(): catchswitch: preserve PostDomTree
When removing catchpad's from catchswitch, if that removes a successor, we need to record that in DomTreeUpdater. This fixes PostDomTree preservation failure in an existing test. This appears to be the single issue that i see in my current test coverage.
This commit is contained in:
parent
1454724215
commit
32fc32317a
|
@ -2286,6 +2286,7 @@ static bool markAliveBlocks(Function &F,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SmallMapVector<BasicBlock *, int, 8> NumPerSuccessorCases;
|
||||||
// Set of unique CatchPads.
|
// Set of unique CatchPads.
|
||||||
SmallDenseMap<CatchPadInst *, detail::DenseSetEmpty, 4,
|
SmallDenseMap<CatchPadInst *, detail::DenseSetEmpty, 4,
|
||||||
CatchPadDenseMapInfo, detail::DenseSetPair<CatchPadInst *>>
|
CatchPadDenseMapInfo, detail::DenseSetPair<CatchPadInst *>>
|
||||||
|
@ -2295,14 +2296,22 @@ static bool markAliveBlocks(Function &F,
|
||||||
E = CatchSwitch->handler_end();
|
E = CatchSwitch->handler_end();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
BasicBlock *HandlerBB = *I;
|
BasicBlock *HandlerBB = *I;
|
||||||
|
++NumPerSuccessorCases[HandlerBB];
|
||||||
auto *CatchPad = cast<CatchPadInst>(HandlerBB->getFirstNonPHI());
|
auto *CatchPad = cast<CatchPadInst>(HandlerBB->getFirstNonPHI());
|
||||||
if (!HandlerSet.insert({CatchPad, Empty}).second) {
|
if (!HandlerSet.insert({CatchPad, Empty}).second) {
|
||||||
|
--NumPerSuccessorCases[HandlerBB];
|
||||||
CatchSwitch->removeHandler(I);
|
CatchSwitch->removeHandler(I);
|
||||||
--I;
|
--I;
|
||||||
--E;
|
--E;
|
||||||
Changed = true;
|
Changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::vector<DominatorTree::UpdateType> Updates;
|
||||||
|
for (const std::pair<BasicBlock *, int> &I : NumPerSuccessorCases)
|
||||||
|
if (I.second == 0)
|
||||||
|
Updates.push_back({DominatorTree::Delete, BB, I.first});
|
||||||
|
if (DTU)
|
||||||
|
DTU->applyUpdates(Updates);
|
||||||
}
|
}
|
||||||
|
|
||||||
Changed |= ConstantFoldTerminator(BB, true, nullptr, DTU);
|
Changed |= ConstantFoldTerminator(BB, true, nullptr, DTU);
|
||||||
|
|
Loading…
Reference in New Issue