1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[SimplifyCFG] Teach simplifyCommonResume() to preserve DomTree

This commit is contained in:
Roman Lebedev 2020-12-19 16:18:04 +03:00
parent 9beb130aa7
commit b81544efa3
3 changed files with 11 additions and 5 deletions

View File

@ -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();
}

View File

@ -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.

View File

@ -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*)