[llvm-branch-commits] [llvm] 2ee7248 - [SimplifyCFG] ConstantFoldTerminator() already knows how to preserve DomTree

Roman Lebedev via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Dec 17 13:43:45 PST 2020


Author: Roman Lebedev
Date: 2020-12-18T00:37:22+03:00
New Revision: 2ee724863e9cfe631fd7eb7eb63f8b795d68a388

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

LOG: [SimplifyCFG] ConstantFoldTerminator() already knows how to preserve DomTree

... so just ensure that we pass DomTreeUpdater it into it.

Fixes DomTree preservation for a number of tests,
all of which are marked as such so that they do not regress.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    llvm/test/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll
    llvm/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll
    llvm/test/Transforms/SimplifyCFG/2011-03-08-UnreachableUse.ll
    llvm/test/Transforms/SimplifyCFG/fold-debug-info.ll
    llvm/test/Transforms/SimplifyCFG/implied-cond-matching-false-dest.ll
    llvm/test/Transforms/SimplifyCFG/implied-cond-matching.ll
    llvm/test/Transforms/SimplifyCFG/implied-cond.ll
    llvm/test/Transforms/SimplifyCFG/indirectbr.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index f39ab25ee64a..9e4650fefff7 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -6322,7 +6322,8 @@ bool SimplifyCFGOpt::simplifyOnce(BasicBlock *BB) {
 
   // Check to see if we can constant propagate this terminator instruction
   // away...
-  Changed |= ConstantFoldTerminator(BB, true);
+  Changed |= ConstantFoldTerminator(BB, /*DeleteDeadConditions=*/true,
+                                    /*TLI=*/nullptr, DTU);
 
   // Check for and eliminate duplicate PHI nodes in this block.
   Changed |= EliminateDuplicatePHINodes(BB);

diff  --git a/llvm/test/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll b/llvm/test/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll
index fafe73b2b4ef..69803400a683 100644
--- a/llvm/test/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll
+++ b/llvm/test/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -simplifycfg -disable-output
+; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -disable-output
 
 define void @symhash_add() {
 entry:

diff  --git a/llvm/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll b/llvm/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll
index 6b216f598efb..a2477f2f3a66 100644
--- a/llvm/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll
+++ b/llvm/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -simplifycfg -disable-output
+; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -disable-output
 ; PR 2777
 @g_103 = common global i32 0		; <i32*> [#uses=1]
 

diff  --git a/llvm/test/Transforms/SimplifyCFG/2011-03-08-UnreachableUse.ll b/llvm/test/Transforms/SimplifyCFG/2011-03-08-UnreachableUse.ll
index 329774e22429..772912c645b3 100644
--- a/llvm/test/Transforms/SimplifyCFG/2011-03-08-UnreachableUse.ll
+++ b/llvm/test/Transforms/SimplifyCFG/2011-03-08-UnreachableUse.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
 ; PR9420
 
 ; Note that the crash in PR9420 test is sensitive to the ordering of

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(

diff  --git a/llvm/test/Transforms/SimplifyCFG/implied-cond-matching-false-dest.ll b/llvm/test/Transforms/SimplifyCFG/implied-cond-matching-false-dest.ll
index 1d29813ecfa2..1ad2e88bfd4a 100644
--- a/llvm/test/Transforms/SimplifyCFG/implied-cond-matching-false-dest.ll
+++ b/llvm/test/Transforms/SimplifyCFG/implied-cond-matching-false-dest.ll
@@ -1,4 +1,4 @@
-; RUN: opt %s -S -simplifycfg | FileCheck %s
+; RUN: opt %s -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 | FileCheck %s
 
 declare void @is(i1)
 

diff  --git a/llvm/test/Transforms/SimplifyCFG/implied-cond-matching.ll b/llvm/test/Transforms/SimplifyCFG/implied-cond-matching.ll
index 33fc016bd386..5b1cb821042a 100644
--- a/llvm/test/Transforms/SimplifyCFG/implied-cond-matching.ll
+++ b/llvm/test/Transforms/SimplifyCFG/implied-cond-matching.ll
@@ -1,4 +1,4 @@
-; RUN: opt %s -S -simplifycfg | FileCheck %s
+; RUN: opt %s -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 | FileCheck %s
 
 declare void @dead()
 declare void @alive()

diff  --git a/llvm/test/Transforms/SimplifyCFG/implied-cond.ll b/llvm/test/Transforms/SimplifyCFG/implied-cond.ll
index 317adc4c3472..dae7ad85d0fd 100644
--- a/llvm/test/Transforms/SimplifyCFG/implied-cond.ll
+++ b/llvm/test/Transforms/SimplifyCFG/implied-cond.ll
@@ -1,4 +1,4 @@
-; RUN: opt %s -S -simplifycfg | FileCheck %s
+; RUN: opt %s -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 | FileCheck %s
 ; Check for when one branch implies the value of a successors conditional and
 ; it's not simply the same conditional repeated.
 

diff  --git a/llvm/test/Transforms/SimplifyCFG/indirectbr.ll b/llvm/test/Transforms/SimplifyCFG/indirectbr.ll
index 67e23d2fe935..52ef6b77166c 100644
--- a/llvm/test/Transforms/SimplifyCFG/indirectbr.ll
+++ b/llvm/test/Transforms/SimplifyCFG/indirectbr.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
 
 ; SimplifyCFG should eliminate redundant indirectbr edges.
 


        


More information about the llvm-branch-commits mailing list