Skip to content

Commit

Permalink
[NPM] Share pass building options with legacy PM
Browse files Browse the repository at this point in the history
We should share options when possible.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D91741
  • Loading branch information
aeubanks committed Nov 23, 2020
1 parent 5b8e4a1 commit 3c811ce
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 67 deletions.
8 changes: 4 additions & 4 deletions llvm/lib/Analysis/CallGraphSCCPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ using namespace llvm;

#define DEBUG_TYPE "cgscc-passmgr"

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

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

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

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

MaxSCCIterations.updateMax(Iteration);
}
Expand Down
47 changes: 9 additions & 38 deletions llvm/lib/Passes/PassBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,26 +233,7 @@

using namespace llvm;

static cl::opt<unsigned> MaxDevirtIterations("pm-max-devirt-iterations",
cl::ReallyHidden, cl::init(4));
static cl::opt<bool>
RunPartialInlining("enable-npm-partial-inlining", cl::init(false),
cl::Hidden, cl::ZeroOrMore,
cl::desc("Run Partial inlinining pass"));

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

static cl::opt<bool>
RunNewGVN("enable-npm-newgvn", cl::init(false),
cl::Hidden, cl::ZeroOrMore,
cl::desc("Run NewGVN instead of GVN"));

static cl::opt<bool> EnableGVNHoist(
"enable-npm-gvn-hoist", cl::init(false), cl::Hidden,
cl::desc("Enable the GVN hoisting pass for the new PM (default = off)"));
extern cl::opt<unsigned> MaxDevirtIterations;

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

static cl::opt<bool> EnableGVNSink(
"enable-npm-gvn-sink", cl::init(false), cl::Hidden,
cl::desc("Enable the GVN hoisting pass for the new PM (default = off)"));

static cl::opt<bool> EnableUnrollAndJam(
"enable-npm-unroll-and-jam", cl::init(false), cl::Hidden,
cl::desc("Enable the Unroll and Jam pass for the new PM (default = off)"));

static cl::opt<bool> EnableLoopFlatten(
"enable-npm-loop-flatten", cl::init(false), cl::Hidden,
cl::desc("Enable the Loop flattening pass for the new PM (default = off)"));

static cl::opt<bool> EnableSyntheticCounts(
"enable-npm-synthetic-counts", cl::init(false), cl::Hidden, cl::ZeroOrMore,
cl::desc("Run synthetic function entry count generation "
Expand All @@ -284,12 +253,6 @@ static cl::opt<bool> EnableSyntheticCounts(
static const Regex DefaultAliasRegex(
"^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$");

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

/// Flag to enable inline deferral during PGO.
static cl::opt<bool>
EnablePGOInlineDeferral("enable-npm-pgo-inline-deferral", cl::init(true),
Expand All @@ -313,8 +276,15 @@ PipelineTuningOptions::PipelineTuningOptions() {
}

extern cl::opt<bool> EnableConstraintElimination;
extern cl::opt<bool> EnableGVNHoist;
extern cl::opt<bool> EnableGVNSink;
extern cl::opt<bool> EnableHotColdSplit;
extern cl::opt<bool> EnableOrderFileInstrumentation;
extern cl::opt<bool> EnableCHR;
extern cl::opt<bool> EnableUnrollAndJam;
extern cl::opt<bool> EnableLoopFlatten;
extern cl::opt<bool> RunNewGVN;
extern cl::opt<bool> RunPartialInlining;

extern cl::opt<bool> FlattenedProfileUsed;

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

extern cl::opt<bool> DisablePreInliner;
extern cl::opt<int> PreInlineThreshold;

const PassBuilder::OptimizationLevel PassBuilder::OptimizationLevel::O0 = {
/*SpeedLevel*/ 0,
Expand Down
38 changes: 19 additions & 19 deletions llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@

using namespace llvm;

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

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

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

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

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

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

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

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

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

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/Inline/crash2.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: opt -inline -sroa -max-cg-scc-iterations=1 -disable-output < %s
; RUN: opt -inline -sroa -max-devirt-iterations=1 -disable-output < %s
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"
target triple = "x86_64-apple-darwin10.3"

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/Inline/gvn-inline-iteration.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: opt -basic-aa -inline -gvn -S -max-cg-scc-iterations=1 < %s | FileCheck %s
; RUN: opt -basic-aa -inline -gvn -S -max-devirt-iterations=1 < %s | FileCheck %s
; rdar://6295824 and PR6724

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"
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/Transforms/LoopUnrollAndJam/opt-levels.ll
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; 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
; 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
; 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
; 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
; 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
; 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
; 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
; 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

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

0 comments on commit 3c811ce

Please sign in to comment.