[llvm-branch-commits] [llvm] b7d00e2 - [SimplifyCFG] Teach simplifySingleResume() to preserve DomTree

Roman Lebedev via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Dec 19 13:23:24 PST 2020


Author: Roman Lebedev
Date: 2020-12-20T00:18:34+03:00
New Revision: b7d00e29b772511da268643488fde8af3645e5d2

URL: https://github.com/llvm/llvm-project/commit/b7d00e29b772511da268643488fde8af3645e5d2
DIFF: https://github.com/llvm/llvm-project/commit/b7d00e29b772511da268643488fde8af3645e5d2.diff

LOG: [SimplifyCFG] Teach simplifySingleResume() to preserve DomTree

Added: 
    

Modified: 
    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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index ced2b6853db7..fec2a678182a 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -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;
 }
 

diff  --git a/llvm/test/Transforms/SimplifyCFG/2011-09-05-TrivialLPad.ll b/llvm/test/Transforms/SimplifyCFG/2011-09-05-TrivialLPad.ll
index 111434b7fcdb..3a70248452fb 100644
--- a/llvm/test/Transforms/SimplifyCFG/2011-09-05-TrivialLPad.ll
+++ b/llvm/test/Transforms/SimplifyCFG/2011-09-05-TrivialLPad.ll
@@ -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

diff  --git a/llvm/test/Transforms/SimplifyCFG/X86/2010-03-30-InvokeCrash.ll b/llvm/test/Transforms/SimplifyCFG/X86/2010-03-30-InvokeCrash.ll
index d545739bc745..d97af9dc2916 100644
--- a/llvm/test/Transforms/SimplifyCFG/X86/2010-03-30-InvokeCrash.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/2010-03-30-InvokeCrash.ll
@@ -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"

diff  --git a/llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll b/llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll
index 0929e64a5b3b..bf832111fbae 100644
--- a/llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll
+++ b/llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll
@@ -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()
 

diff  --git a/llvm/test/Transforms/SimplifyCFG/lifetime-landingpad.ll b/llvm/test/Transforms/SimplifyCFG/lifetime-landingpad.ll
index 20424382b3be..f6afcf0a658c 100644
--- a/llvm/test/Transforms/SimplifyCFG/lifetime-landingpad.ll
+++ b/llvm/test/Transforms/SimplifyCFG/lifetime-landingpad.ll
@@ -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 {


        


More information about the llvm-branch-commits mailing list