Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ static cl::opt<bool> UserSpeculateUnpredictables(
"speculate-unpredictables", cl::Hidden, cl::init(false),
cl::desc("Speculate unpredictable branches (default = false)"));

static cl::opt<bool> DisableSimplifyCFG(
"disable-simplify-cfg", cl::Hidden, cl::init(false),
cl::desc("Disable simplify cfg"));

STATISTIC(NumSimpl, "Number of blocks simplified");

static bool
Expand Down Expand Up @@ -307,6 +311,9 @@ static bool simplifyFunctionCFG(Function &F, const TargetTransformInfo &TTI,
(DT && DT->verify(DominatorTree::VerificationLevel::Full))) &&
"Original domtree is invalid?");

if (DisableSimplifyCFG)
return false;

bool Changed = simplifyFunctionCFGImpl(F, TTI, DT, Options);

assert((!RequireAndPreserveDomTree ||
Expand Down
13 changes: 13 additions & 0 deletions llvm/test/Transforms/SimplifyCFG/disable-simplify-cfg.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt < %s -passes=simplifycfg -disable-simplify-cfg=true -S | FileCheck %s

define void @test1() {
; CHECK-LABEL: define void @test1() {
; CHECK-NEXT: br label %[[BB1:.*]]
; CHECK: [[BB1]]:
; CHECK-NEXT: ret void
;
br label %1
ret void
}

Loading