[SimplifyCFG] Teach simplifySingleResume() to preserve DomTree
authorRoman Lebedev <lebedev.ri@gmail.com>
Sat, 19 Dec 2020 13:52:54 +0000 (16:52 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Sat, 19 Dec 2020 21:18:34 +0000 (00:18 +0300)
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/2011-09-05-TrivialLPad.ll
llvm/test/Transforms/SimplifyCFG/X86/2010-03-30-InvokeCrash.ll
llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll
llvm/test/Transforms/SimplifyCFG/lifetime-landingpad.ll

index ced2b68..fec2a67 100644 (file)
@@ -4200,14 +4200,17 @@ bool SimplifyCFGOpt::simplifySingleResume(ResumeInst *RI) {
   // Turn all invokes that unwind here into calls and delete the basic block.
   for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE;) {
     BasicBlock *Pred = *PI++;
-    removeUnwindEdge(Pred);
+    removeUnwindEdge(Pred, DTU);
     ++NumInvokes;
   }
 
   // The landingpad is now unreachable.  Zap it.
   if (LoopHeaders)
     LoopHeaders->erase(BB);
-  BB->eraseFromParent();
+  if (DTU)
+    DTU->deleteBB(BB);
+  else
+    BB->eraseFromParent();
   return true;
 }
 
index 111434b..3a70248 100644 (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
 
 ; CHECK-NOT: invoke
 ; CHECK-NOT: landingpad
index d545739..d97af9d 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -simplifycfg -disable-output < %s
+; RUN: opt -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -disable-output < %s
 ; END.
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
 target triple = "x86_64-unknown-linux-gnu"
index 0929e64..bf83211 100644 (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
 
 declare void @bar()
 
index 2042438..f6afcf0 100644 (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
 
 ; CHECK-LABEL: define void @foo
 define void @foo() personality i32 (...)* @__gxx_personality_v0 {