mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[NFCI][SimplifyCFG] removeEmptyCleanup(): use DeleteDeadBlock()
This required some changes to, instead of eagerly making PHI's in the UnwindDest valid as-if the BB is already not a predecessor, to be valid while BB is still a predecessor.
This commit is contained in:
parent
a81902844e
commit
1a82744191
@ -4486,9 +4486,6 @@ static bool removeEmptyCleanup(CleanupReturnInst *RI, DomTreeUpdater *DTU) {
|
||||
Value *SrcVal = DestPN.getIncomingValue(Idx);
|
||||
PHINode *SrcPN = dyn_cast<PHINode>(SrcVal);
|
||||
|
||||
// Remove the entry for the block we are deleting.
|
||||
DestPN.removeIncomingValue(Idx, false);
|
||||
|
||||
bool NeedPHITranslation = SrcPN && SrcPN->getParent() == BB;
|
||||
for (auto *Pred : predecessors(BB)) {
|
||||
Value *Incoming =
|
||||
@ -4516,12 +4513,15 @@ static bool removeEmptyCleanup(CleanupReturnInst *RI, DomTreeUpdater *DTU) {
|
||||
if (pred != BB)
|
||||
PN.addIncoming(&PN, pred);
|
||||
PN.moveBefore(InsertPt);
|
||||
// Also, add a dummy incoming value for the original BB itself,
|
||||
// so that the PHI is well-formed until we drop said predecessor.
|
||||
PN.addIncoming(UndefValue::get(PN.getType()), BB);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<DominatorTree::UpdateType> Updates;
|
||||
|
||||
// We use make_early_inc_range here because we may remove some predecessors.
|
||||
// We use make_early_inc_range here because we will remove all predecessors.
|
||||
for (BasicBlock *PredBB : llvm::make_early_inc_range(predecessors(BB))) {
|
||||
if (UnwindDest == nullptr) {
|
||||
if (DTU) {
|
||||
@ -4531,6 +4531,7 @@ static bool removeEmptyCleanup(CleanupReturnInst *RI, DomTreeUpdater *DTU) {
|
||||
removeUnwindEdge(PredBB, DTU);
|
||||
++NumInvokes;
|
||||
} else {
|
||||
BB->removePredecessor(PredBB);
|
||||
Instruction *TI = PredBB->getTerminator();
|
||||
TI->replaceUsesOfWith(BB, UnwindDest);
|
||||
if (DTU) {
|
||||
@ -4540,12 +4541,10 @@ static bool removeEmptyCleanup(CleanupReturnInst *RI, DomTreeUpdater *DTU) {
|
||||
}
|
||||
}
|
||||
|
||||
if (DTU) {
|
||||
if (DTU)
|
||||
DTU->applyUpdates(Updates);
|
||||
DTU->deleteBB(BB);
|
||||
} else
|
||||
// The cleanup pad is now unreachable. Zap it.
|
||||
BB->eraseFromParent();
|
||||
|
||||
DeleteDeadBlock(BB, DTU);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user