Skip to content

Commit 3c811ce

Browse files
committed
[NPM] Share pass building options with legacy PM
We should share options when possible. Reviewed By: asbirlea Differential Revision: https://reviews.llvm.org/D91741
1 parent 5b8e4a1 commit 3c811ce

File tree

6 files changed

+38
-67
lines changed

6 files changed

+38
-67
lines changed

llvm/lib/Analysis/CallGraphSCCPass.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ using namespace llvm;
4343

4444
#define DEBUG_TYPE "cgscc-passmgr"
4545

46-
static cl::opt<unsigned>
47-
MaxIterations("max-cg-scc-iterations", cl::ReallyHidden, cl::init(4));
46+
cl::opt<unsigned> MaxDevirtIterations("max-devirt-iterations", cl::ReallyHidden,
47+
cl::init(4));
4848

4949
STATISTIC(MaxSCCIterations, "Maximum CGSCCPassMgr iterations on one SCC");
5050

@@ -539,12 +539,12 @@ bool CGPassManager::runOnModule(Module &M) {
539539
<< '\n');
540540
DevirtualizedCall = false;
541541
Changed |= RunAllPassesOnSCC(CurSCC, CG, DevirtualizedCall);
542-
} while (Iteration++ < MaxIterations && DevirtualizedCall);
542+
} while (Iteration++ < MaxDevirtIterations && DevirtualizedCall);
543543

544544
if (DevirtualizedCall)
545545
LLVM_DEBUG(dbgs() << " CGSCCPASSMGR: Stopped iteration after "
546546
<< Iteration
547-
<< " times, due to -max-cg-scc-iterations\n");
547+
<< " times, due to -max-devirt-iterations\n");
548548

549549
MaxSCCIterations.updateMax(Iteration);
550550
}

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -233,26 +233,7 @@
233233

234234
using namespace llvm;
235235

236-
static cl::opt<unsigned> MaxDevirtIterations("pm-max-devirt-iterations",
237-
cl::ReallyHidden, cl::init(4));
238-
static cl::opt<bool>
239-
RunPartialInlining("enable-npm-partial-inlining", cl::init(false),
240-
cl::Hidden, cl::ZeroOrMore,
241-
cl::desc("Run Partial inlinining pass"));
242-
243-
static cl::opt<int> PreInlineThreshold(
244-
"npm-preinline-threshold", cl::Hidden, cl::init(75), cl::ZeroOrMore,
245-
cl::desc("Control the amount of inlining in pre-instrumentation inliner "
246-
"(default = 75)"));
247-
248-
static cl::opt<bool>
249-
RunNewGVN("enable-npm-newgvn", cl::init(false),
250-
cl::Hidden, cl::ZeroOrMore,
251-
cl::desc("Run NewGVN instead of GVN"));
252-
253-
static cl::opt<bool> EnableGVNHoist(
254-
"enable-npm-gvn-hoist", cl::init(false), cl::Hidden,
255-
cl::desc("Enable the GVN hoisting pass for the new PM (default = off)"));
236+
extern cl::opt<unsigned> MaxDevirtIterations;
256237

257238
static cl::opt<InliningAdvisorMode> UseInlineAdvisor(
258239
"enable-ml-inliner", cl::init(InliningAdvisorMode::Default), cl::Hidden,
@@ -264,18 +245,6 @@ static cl::opt<InliningAdvisorMode> UseInlineAdvisor(
264245
clEnumValN(InliningAdvisorMode::Release, "release",
265246
"Use release mode (AOT-compiled model).")));
266247

267-
static cl::opt<bool> EnableGVNSink(
268-
"enable-npm-gvn-sink", cl::init(false), cl::Hidden,
269-
cl::desc("Enable the GVN hoisting pass for the new PM (default = off)"));
270-
271-
static cl::opt<bool> EnableUnrollAndJam(
272-
"enable-npm-unroll-and-jam", cl::init(false), cl::Hidden,
273-
cl::desc("Enable the Unroll and Jam pass for the new PM (default = off)"));
274-
275-
static cl::opt<bool> EnableLoopFlatten(
276-
"enable-npm-loop-flatten", cl::init(false), cl::Hidden,
277-
cl::desc("Enable the Loop flattening pass for the new PM (default = off)"));
278-
279248
static cl::opt<bool> EnableSyntheticCounts(
280249
"enable-npm-synthetic-counts", cl::init(false), cl::Hidden, cl::ZeroOrMore,
281250
cl::desc("Run synthetic function entry count generation "
@@ -284,12 +253,6 @@ static cl::opt<bool> EnableSyntheticCounts(
284253
static const Regex DefaultAliasRegex(
285254
"^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$");
286255

287-
// This option is used in simplifying testing SampleFDO optimizations for
288-
// profile loading.
289-
static cl::opt<bool>
290-
EnableCHR("enable-chr-npm", cl::init(true), cl::Hidden,
291-
cl::desc("Enable control height reduction optimization (CHR)"));
292-
293256
/// Flag to enable inline deferral during PGO.
294257
static cl::opt<bool>
295258
EnablePGOInlineDeferral("enable-npm-pgo-inline-deferral", cl::init(true),
@@ -313,8 +276,15 @@ PipelineTuningOptions::PipelineTuningOptions() {
313276
}
314277

315278
extern cl::opt<bool> EnableConstraintElimination;
279+
extern cl::opt<bool> EnableGVNHoist;
280+
extern cl::opt<bool> EnableGVNSink;
316281
extern cl::opt<bool> EnableHotColdSplit;
317282
extern cl::opt<bool> EnableOrderFileInstrumentation;
283+
extern cl::opt<bool> EnableCHR;
284+
extern cl::opt<bool> EnableUnrollAndJam;
285+
extern cl::opt<bool> EnableLoopFlatten;
286+
extern cl::opt<bool> RunNewGVN;
287+
extern cl::opt<bool> RunPartialInlining;
318288

319289
extern cl::opt<bool> FlattenedProfileUsed;
320290

@@ -324,6 +294,7 @@ extern cl::opt<bool> EnableKnowledgeRetention;
324294
extern cl::opt<bool> EnableMatrix;
325295

326296
extern cl::opt<bool> DisablePreInliner;
297+
extern cl::opt<int> PreInlineThreshold;
327298

328299
const PassBuilder::OptimizationLevel PassBuilder::OptimizationLevel::O0 = {
329300
/*SpeedLevel*/ 0,

llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151

5252
using namespace llvm;
5353

54-
static cl::opt<bool>
55-
RunPartialInlining("enable-partial-inlining", cl::init(false), cl::Hidden,
56-
cl::ZeroOrMore, cl::desc("Run Partial inlinining pass"));
54+
cl::opt<bool> RunPartialInlining("enable-partial-inlining", cl::init(false),
55+
cl::Hidden, cl::ZeroOrMore,
56+
cl::desc("Run Partial inlinining pass"));
5757

5858
static cl::opt<bool>
5959
UseGVNAfterVectorization("use-gvn-after-vectorization",
@@ -68,8 +68,8 @@ static cl::opt<bool>
6868
RunLoopRerolling("reroll-loops", cl::Hidden,
6969
cl::desc("Run the loop rerolling pass"));
7070

71-
static cl::opt<bool> RunNewGVN("enable-newgvn", cl::init(false), cl::Hidden,
72-
cl::desc("Run the NewGVN pass"));
71+
cl::opt<bool> RunNewGVN("enable-newgvn", cl::init(false), cl::Hidden,
72+
cl::desc("Run the NewGVN pass"));
7373

7474
// Experimental option to use CFL-AA
7575
enum class CFLAAType { None, Steensgaard, Andersen, Both };
@@ -88,13 +88,13 @@ static cl::opt<bool> EnableLoopInterchange(
8888
"enable-loopinterchange", cl::init(false), cl::Hidden,
8989
cl::desc("Enable the new, experimental LoopInterchange Pass"));
9090

91-
static cl::opt<bool> EnableUnrollAndJam("enable-unroll-and-jam",
92-
cl::init(false), cl::Hidden,
93-
cl::desc("Enable Unroll And Jam Pass"));
91+
cl::opt<bool> EnableUnrollAndJam("enable-unroll-and-jam", cl::init(false),
92+
cl::Hidden,
93+
cl::desc("Enable Unroll And Jam Pass"));
9494

95-
static cl::opt<bool> EnableLoopFlatten("enable-loop-flatten", cl::init(false),
96-
cl::Hidden,
97-
cl::desc("Enable the LoopFlatten Pass"));
95+
cl::opt<bool> EnableLoopFlatten("enable-loop-flatten", cl::init(false),
96+
cl::Hidden,
97+
cl::desc("Enable the LoopFlatten Pass"));
9898

9999
static cl::opt<bool>
100100
EnablePrepareForThinLTO("prepare-for-thinlto", cl::init(false), cl::Hidden,
@@ -115,14 +115,14 @@ cl::opt<bool>
115115
DisablePreInliner("disable-preinline", cl::init(false), cl::Hidden,
116116
cl::desc("Disable pre-instrumentation inliner"));
117117

118-
static cl::opt<int> PreInlineThreshold(
118+
cl::opt<int> PreInlineThreshold(
119119
"preinline-threshold", cl::Hidden, cl::init(75), cl::ZeroOrMore,
120120
cl::desc("Control the amount of inlining in pre-instrumentation inliner "
121121
"(default = 75)"));
122122

123-
static cl::opt<bool> EnableGVNHoist(
124-
"enable-gvn-hoist", cl::init(false), cl::ZeroOrMore,
125-
cl::desc("Enable the GVN hoisting pass (default = off)"));
123+
cl::opt<bool>
124+
EnableGVNHoist("enable-gvn-hoist", cl::init(false), cl::ZeroOrMore,
125+
cl::desc("Enable the GVN hoisting pass (default = off)"));
126126

127127
static cl::opt<bool>
128128
DisableLibCallsShrinkWrap("disable-libcalls-shrinkwrap", cl::init(false),
@@ -134,13 +134,13 @@ static cl::opt<bool> EnableSimpleLoopUnswitch(
134134
cl::desc("Enable the simple loop unswitch pass. Also enables independent "
135135
"cleanup passes integrated into the loop pass manager pipeline."));
136136

137-
static cl::opt<bool> EnableGVNSink(
138-
"enable-gvn-sink", cl::init(false), cl::ZeroOrMore,
139-
cl::desc("Enable the GVN sinking pass (default = off)"));
137+
cl::opt<bool>
138+
EnableGVNSink("enable-gvn-sink", cl::init(false), cl::ZeroOrMore,
139+
cl::desc("Enable the GVN sinking pass (default = off)"));
140140

141141
// This option is used in simplifying testing SampleFDO optimizations for
142142
// profile loading.
143-
static cl::opt<bool>
143+
cl::opt<bool>
144144
EnableCHR("enable-chr", cl::init(true), cl::Hidden,
145145
cl::desc("Enable control height reduction optimization (CHR)"));
146146

llvm/test/Transforms/Inline/crash2.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt -inline -sroa -max-cg-scc-iterations=1 -disable-output < %s
1+
; RUN: opt -inline -sroa -max-devirt-iterations=1 -disable-output < %s
22
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"
33
target triple = "x86_64-apple-darwin10.3"
44

llvm/test/Transforms/Inline/gvn-inline-iteration.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt -basic-aa -inline -gvn -S -max-cg-scc-iterations=1 < %s | FileCheck %s
1+
; RUN: opt -basic-aa -inline -gvn -S -max-devirt-iterations=1 < %s | FileCheck %s
22
; rdar://6295824 and PR6724
33

44
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"

llvm/test/Transforms/LoopUnrollAndJam/opt-levels.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
; RUN: opt < %s -S -passes="default<O2>" -unroll-runtime=true -enable-npm-unroll-and-jam -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=O2
2-
; RUN: opt < %s -S -passes="default<O3>" -unroll-runtime=true -enable-npm-unroll-and-jam -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=O3
3-
; RUN: opt < %s -S -passes="default<Os>" -unroll-runtime=true -enable-npm-unroll-and-jam -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=Os
4-
; RUN: opt < %s -S -passes="default<Oz>" -unroll-runtime=true -enable-npm-unroll-and-jam -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=Oz
1+
; RUN: opt < %s -S -passes="default<O2>" -unroll-runtime=true -enable-unroll-and-jam -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=O2
2+
; RUN: opt < %s -S -passes="default<O3>" -unroll-runtime=true -enable-unroll-and-jam -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=O3
3+
; RUN: opt < %s -S -passes="default<Os>" -unroll-runtime=true -enable-unroll-and-jam -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=Os
4+
; RUN: opt < %s -S -passes="default<Oz>" -unroll-runtime=true -enable-unroll-and-jam -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=Oz
55

66
; Check that Os and Oz are optimized like O2, not like O3. To easily highlight
77
; the behavior, we artificially disable unrolling for anything but O3 by setting

0 commit comments

Comments
 (0)