[SimplifyCFG] Teach SimplifyCondBranchToTwoReturns() to preserve DomTree, part 2
authorRoman Lebedev <lebedev.ri@gmail.com>
Sat, 19 Dec 2020 17:07:26 +0000 (20:07 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Sat, 19 Dec 2020 21:18:36 +0000 (00:18 +0300)
... for the custom case returning void.

llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/fold-debug-info.ll

index 8ee7e57..3bc0997 100644 (file)
@@ -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;
   }
 
index bc5a937..bf3a283 100644 (file)
@@ -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(