Skip to content

Commit 664881c

Browse files
committed
[SimplifyCFG] Add command-line option to disable the pass
The option is useful for some of the experiments we're doing. I don't see any harm in having such option and the ability to disable the pass.
1 parent 418e07b commit 664881c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ static cl::opt<bool> UserSpeculateUnpredictables(
8585
"speculate-unpredictables", cl::Hidden, cl::init(false),
8686
cl::desc("Speculate unpredictable branches (default = false)"));
8787

88+
static cl::opt<bool> DisableSimplifyCFG(
89+
"disable-simplify-cfg", cl::Hidden, cl::init(false),
90+
cl::desc("Disable simplify cfg"));
91+
8892
STATISTIC(NumSimpl, "Number of blocks simplified");
8993

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

314+
if (DisableSimplifyCFG)
315+
return false;
316+
310317
bool Changed = simplifyFunctionCFGImpl(F, TTI, DT, Options);
311318

312319
assert((!RequireAndPreserveDomTree ||
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt < %s -passes=simplifycfg -disable-simplify-cfg=true -S | FileCheck %s
3+
4+
define void @test1() {
5+
; CHECK-LABEL: define void @test1() {
6+
; CHECK-NEXT: br label %[[BB1:.*]]
7+
; CHECK: [[BB1]]:
8+
; CHECK-NEXT: ret void
9+
;
10+
br label %1
11+
ret void
12+
}
13+

0 commit comments

Comments
 (0)