forked from OSchip/llvm-project
[SimplifyCFG] Teach simplifyCommonResume() to preserve DomTree
This commit is contained in:
parent
76e74d9395
commit
c209b88dd4
|
@ -4159,7 +4159,7 @@ bool SimplifyCFGOpt::simplifyCommonResume(ResumeInst *RI) {
|
|||
for (pred_iterator PI = pred_begin(TrivialBB), PE = pred_end(TrivialBB);
|
||||
PI != PE;) {
|
||||
BasicBlock *Pred = *PI++;
|
||||
removeUnwindEdge(Pred);
|
||||
removeUnwindEdge(Pred, DTU);
|
||||
++NumInvokes;
|
||||
}
|
||||
|
||||
|
@ -4170,11 +4170,17 @@ bool SimplifyCFGOpt::simplifyCommonResume(ResumeInst *RI) {
|
|||
// predecessors.
|
||||
TrivialBB->getTerminator()->eraseFromParent();
|
||||
new UnreachableInst(RI->getContext(), TrivialBB);
|
||||
if (DTU)
|
||||
DTU->applyUpdatesPermissive({{DominatorTree::Delete, TrivialBB, BB}});
|
||||
}
|
||||
|
||||
// Delete the resume block if all its predecessors have been removed.
|
||||
if (pred_empty(BB))
|
||||
BB->eraseFromParent();
|
||||
if (pred_empty(BB)) {
|
||||
if (DTU)
|
||||
DTU->deleteBB(BB);
|
||||
else
|
||||
BB->eraseFromParent();
|
||||
}
|
||||
|
||||
return !TrivialUnwindBlocks.empty();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; RUN: opt < %s -simplifycfg -S | FileCheck %s
|
||||
; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
|
||||
|
||||
;; Test case for bug 25299, contributed by David Majnemer.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -simplifycfg -S | FileCheck %s
|
||||
; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
|
||||
|
||||
declare void @llvm.lifetime.start.p0i8(i64, i8*)
|
||||
declare void @llvm.lifetime.end.p0i8(i64, i8*)
|
||||
|
|
Loading…
Reference in New Issue