[llvm] 6a1617d - [SimplifyCFG] Teach SimplifyCondBranchToTwoReturns() to preserve DomTree, part 2
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 19 13:19:27 PST 2020
Author: Roman Lebedev
Date: 2020-12-20T00:18:36+03:00
New Revision: 6a1617d67ccdf359d4250267be4431530308f351
URL: https://github.com/llvm/llvm-project/commit/6a1617d67ccdf359d4250267be4431530308f351
DIFF: https://github.com/llvm/llvm-project/commit/6a1617d67ccdf359d4250267be4431530308f351.diff
LOG: [SimplifyCFG] Teach SimplifyCondBranchToTwoReturns() to preserve DomTree, part 2
... for the custom case returning void.
Added:
Modified:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/fold-debug-info.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 8ee7e57a6135..3bc09978489e 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2631,6 +2631,10 @@ bool SimplifyCFGOpt::SimplifyCondBranchToTwoReturns(BranchInst *BI,
FalseSucc->removePredecessor(BB);
Builder.CreateRetVoid();
EraseTerminatorAndDCECond(BI);
+ if (DTU) {
+ DTU->applyUpdatesPermissive({{DominatorTree::Delete, BB, TrueSucc},
+ {DominatorTree::Delete, BB, FalseSucc}});
+ }
return true;
}
diff --git a/llvm/test/Transforms/SimplifyCFG/fold-debug-info.ll b/llvm/test/Transforms/SimplifyCFG/fold-debug-info.ll
index bc5a93745375..bf3a283cf941 100644
--- a/llvm/test/Transforms/SimplifyCFG/fold-debug-info.ll
+++ b/llvm/test/Transforms/SimplifyCFG/fold-debug-info.ll
@@ -1,6 +1,6 @@
;; Check that we don't crash. PR37300.
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt %s -S -simplifycfg | FileCheck %s
+; RUN: opt %s -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 | FileCheck %s
define void @patatino() {
; CHECK-LABEL: @patatino(
More information about the llvm-commits
mailing list