Skip to content

Commit

Permalink
[SimplifyCFG] ConstantFoldTerminator() already knows how to preserve …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
LebedevRI committed Dec 17, 2020
1 parent 164e084 commit 2ee7248
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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]

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/SimplifyCFG/fold-debug-info.ll
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/SimplifyCFG/implied-cond-matching.ll
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/SimplifyCFG/implied-cond.ll
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/SimplifyCFG/indirectbr.ll
Original file line number Diff line number Diff line change
@@ -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.

Expand Down

0 comments on commit 2ee7248

Please sign in to comment.