[llvm] b43b59f - Expose `attributor-disable` to the new and old pass managers
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 5 20:31:13 PDT 2020
Author: Tarindu Jayatilaka
Date: 2020-04-05T22:29:34-05:00
New Revision: b43b59fcc0e7743ea5112ca397c0aae810091e5c
URL: https://github.com/llvm/llvm-project/commit/b43b59fcc0e7743ea5112ca397c0aae810091e5c
DIFF: https://github.com/llvm/llvm-project/commit/b43b59fcc0e7743ea5112ca397c0aae810091e5c.diff
LOG: Expose `attributor-disable` to the new and old pass managers
The new and old pass managers (PassManagerBuilder.cpp and
PassBuilder.cpp) are exposed to an `extern` declaration of
`attributor-disable` option which will guard the addition of the
attributor passes to the pass pipelines.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D76871
Added:
Modified:
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/new-pm-thinlto-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
llvm/test/Other/opt-O2-pipeline.ll
llvm/test/Other/opt-O3-pipeline.ll
llvm/test/Other/opt-Os-pipeline.ll
llvm/test/Other/pass-pipelines.ll
llvm/test/Transforms/Attributor/ArgumentPromotion/invalidation.ll
Removed:
################################################################################
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index c56c35866dda..b7b4bff93373 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -258,6 +258,8 @@ extern cl::opt<bool> EnableOrderFileInstrumentation;
extern cl::opt<bool> FlattenedProfileUsed;
+extern cl::opt<bool> DisableAttributor;
+
const PassBuilder::OptimizationLevel PassBuilder::OptimizationLevel::O0 = {
/*SpeedLevel*/ 0,
/*SizeLevel*/ 0};
@@ -765,7 +767,9 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
MPM.addPass(PGOIndirectCallPromotion(Phase == ThinLTOPhase::PostLink,
true /* SamplePGO */));
}
- MPM.addPass(AttributorPass());
+
+ if (!DisableAttributor)
+ MPM.addPass(AttributorPass());
// Interprocedural constant propagation now that basic cleanup has occurred
// and prior to optimizing globals.
@@ -848,7 +852,8 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
IP.HotCallSiteThreshold = 0;
MainCGPipeline.addPass(InlinerPass(IP));
- MainCGPipeline.addPass(AttributorCGSCCPass());
+ if (!DisableAttributor)
+ MainCGPipeline.addPass(AttributorCGSCCPass());
if (PTO.Coroutines)
MainCGPipeline.addPass(CoroSplitPass());
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 483cb710c4e8..ec9252c3d5d1 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -160,11 +160,6 @@ static cl::opt<bool> VerifyMaxFixpointIterations(
cl::desc("Verify that max-iterations is a tight bound for a fixpoint"),
cl::init(false));
-static cl::opt<bool> DisableAttributor(
- "attributor-disable", cl::Hidden,
- cl::desc("Disable the attributor inter-procedural deduction pass."),
- cl::init(true));
-
static cl::opt<bool> AnnotateDeclarationCallSites(
"attributor-annotate-decl-cs", cl::Hidden,
cl::desc("Annotate call sites of function declarations."), cl::init(false));
@@ -8849,7 +8844,7 @@ static bool runAttributorOnFunctions(InformationCache &InfoCache,
SetVector<Function *> &Functions,
AnalysisGetter &AG,
CallGraphUpdater &CGUpdater) {
- if (DisableAttributor || Functions.empty())
+ if (Functions.empty())
return false;
LLVM_DEBUG(dbgs() << "[Attributor] Run on module with " << Functions.size()
diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
index e61d8b1ce6ee..bce64e71f552 100644
--- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -153,6 +153,11 @@ static cl::opt<bool>
EnableMatrix("enable-matrix", cl::init(false), cl::Hidden,
cl::desc("Enable lowering of the matrix intrinsics"));
+cl::opt<bool> DisableAttributor(
+ "attributor-disable", cl::Hidden,
+ cl::desc("Disable the attributor inter-procedural deduction pass."),
+ cl::init(true));
+
PassManagerBuilder::PassManagerBuilder() {
OptLevel = 2;
SizeLevel = 0;
@@ -547,7 +552,8 @@ void PassManagerBuilder::populateModulePassManager(
MPM.add(createInferFunctionAttrsLegacyPass());
// Infer attributes on declarations, call sites, arguments, etc.
- MPM.add(createAttributorLegacyPass());
+ if (!DisableAttributor)
+ MPM.add(createAttributorLegacyPass());
addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);
@@ -595,7 +601,8 @@ void PassManagerBuilder::populateModulePassManager(
}
// Infer attributes on declarations, call sites, arguments, etc. for an SCC.
- MPM.add(createAttributorCGSCCLegacyPass());
+ if (!DisableAttributor)
+ MPM.add(createAttributorCGSCCLegacyPass());
// Try to perform OpenMP specific optimizations. This is a (quick!) no-op if
// there are no OpenMP runtime calls present in the module.
@@ -881,7 +888,8 @@ void PassManagerBuilder::addLTOOptimizationPasses(legacy::PassManagerBase &PM) {
PM.add(createCalledValuePropagationPass());
// Infer attributes on declarations, call sites, arguments, etc.
- PM.add(createAttributorLegacyPass());
+ if (!DisableAttributor)
+ PM.add(createAttributorLegacyPass());
}
// Infer attributes about definitions. The readnone attribute in particular is
@@ -935,7 +943,8 @@ void PassManagerBuilder::addLTOOptimizationPasses(legacy::PassManagerBase &PM) {
addPGOInstrPasses(PM, /* IsCS */ true);
// Infer attributes on declarations, call sites, arguments, etc. for an SCC.
- PM.add(createAttributorCGSCCLegacyPass());
+ if (!DisableAttributor)
+ PM.add(createAttributorCGSCCLegacyPass());
// Try to perform OpenMP specific optimizations. This is a (quick!) no-op if
// there are no OpenMP runtime calls present in the module.
diff --git a/llvm/test/Other/new-pm-defaults.ll b/llvm/test/Other/new-pm-defaults.ll
index ca592ef4d21c..16e602643d63 100644
--- a/llvm/test/Other/new-pm-defaults.ll
+++ b/llvm/test/Other/new-pm-defaults.ll
@@ -113,7 +113,6 @@
; CHECK-O-NEXT: Running pass: LowerExpectIntrinsicPass
; CHECK-O3-NEXT: Running pass: CallSiteSplittingPass
; CHECK-O-NEXT: Finished llvm::Function pass manager run.
-; CHECK-O-NEXT: Running pass: AttributorPass
; CHECK-O-NEXT: Running pass: IPSCCPPass
; CHECK-O-NEXT: Running pass: CalledValuePropagationPass
; CHECK-O-NEXT: Running pass: GlobalOptPass
@@ -141,7 +140,6 @@
; CHECK-O-NEXT: Running analysis: OuterAnalysisManagerProxy<{{.*}}LazyCallGraph::SCC{{.*}}>
; CHECK-O-NEXT: Starting CGSCC pass manager run.
; CHECK-O-NEXT: Running pass: InlinerPass
-; CHECK-O-NEXT: Running pass: AttributorCGSCCPass
; CHECK-O-NEXT: Running pass: PostOrderFunctionAttrsPass
; CHECK-O3-NEXT: Running pass: ArgumentPromotionPass
; CHECK-O2-NEXT: Running pass: OpenMPOptPass on (foo)
diff --git a/llvm/test/Other/new-pm-thinlto-defaults.ll b/llvm/test/Other/new-pm-thinlto-defaults.ll
index 8967af5aca5b..9213108cb4a4 100644
--- a/llvm/test/Other/new-pm-thinlto-defaults.ll
+++ b/llvm/test/Other/new-pm-thinlto-defaults.ll
@@ -79,7 +79,6 @@
; CHECK-O-NEXT: Running pass: LowerExpectIntrinsicPass
; CHECK-O3-NEXT: Running pass: CallSiteSplittingPass
; CHECK-O-NEXT: Finished llvm::Function pass manager run.
-; CHECK-O-NEXT: Running pass: AttributorPass
; CHECK-O-NEXT: Running pass: IPSCCPPass
; CHECK-O-NEXT: Running pass: CalledValuePropagationPass
; CHECK-O-NEXT: Running pass: GlobalOptPass
@@ -106,7 +105,6 @@
; CHECK-O-NEXT: Running analysis: OuterAnalysisManagerProxy<{{.*}}LazyCallGraph::SCC{{.*}}>
; CHECK-O-NEXT: Starting CGSCC pass manager run.
; CHECK-O-NEXT: Running pass: InlinerPass
-; CHECK-O-NEXT: Running pass: AttributorCGSCCPass
; CHECK-O-NEXT: Running pass: PostOrderFunctionAttrsPass
; CHECK-O3-NEXT: Running pass: ArgumentPromotionPass
; CHECK-O2-NEXT: Running pass: OpenMPOptPass on (foo)
diff --git a/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
index 1f262b8869dc..779ad480ec9c 100644
--- a/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
+++ b/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
@@ -48,7 +48,6 @@
; CHECK-O-NEXT: Running pass: LowerExpectIntrinsicPass
; CHECK-O3-NEXT: Running pass: CallSiteSplittingPass
; CHECK-O-NEXT: Finished {{.*}}Function pass manager run.
-; CHECK-O-NEXT: Running pass: AttributorPass
; CHECK-O-NEXT: Running pass: IPSCCPPass
; CHECK-O-NEXT: Running pass: CalledValuePropagationPass
; CHECK-O-NEXT: Running pass: GlobalOptPass
@@ -78,7 +77,6 @@
; CHECK-O-NEXT: Running analysis: OuterAnalysisManagerProxy<{{.*}}LazyCallGraph::SCC{{.*}}>
; CHECK-O-NEXT: Starting CGSCC pass manager run.
; CHECK-O-NEXT: Running pass: InlinerPass
-; CHECK-O-NEXT: Running pass: AttributorCGSCCPass
; CHECK-O-NEXT: Running pass: PostOrderFunctionAttrsPass
; CHECK-O3-NEXT: Running pass: ArgumentPromotionPass
; CHECK-O2-NEXT: Running pass: OpenMPOptPass
diff --git a/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
index cceea7f75521..cdc8e92899a7 100644
--- a/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
+++ b/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
@@ -59,7 +59,6 @@
; CHECK-O-NEXT: Running analysis: CallGraphAnalysis
; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}ProfileSummaryAnalysis
; CHECK-O-NEXT: Running pass: PGOIndirectCallPromotion
-; CHECK-O-NEXT: Running pass: AttributorPass
; CHECK-O-NEXT: Running pass: IPSCCPPass
; CHECK-O-NEXT: Running pass: CalledValuePropagationPass
; CHECK-O-NEXT: Running pass: GlobalOptPass
@@ -86,7 +85,6 @@
; CHECK-O-NEXT: Running analysis: OuterAnalysisManagerProxy<{{.*}}LazyCallGraph::SCC{{.*}}>
; CHECK-O-NEXT: Starting CGSCC pass manager run.
; CHECK-O-NEXT: Running pass: InlinerPass
-; CHECK-O-NEXT: Running pass: AttributorCGSCCPass
; CHECK-O-NEXT: Running pass: PostOrderFunctionAttrsPass
; CHECK-O3-NEXT: Running pass: ArgumentPromotionPass
; CHECK-O2-NEXT: Running pass: OpenMPOptPass
diff --git a/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
index 8a26ba562c2c..aad0c00c2d6d 100644
--- a/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
+++ b/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
@@ -1,7 +1,7 @@
; Validate ThinLTO prelink pipeline when we have instrumentation PGO
;
; RUN: llvm-profdata merge %S/Inputs/new-pm-thinlto-prelink-pgo-defaults.proftext -o %t.profdata
-;
+;
; RUN: opt -disable-verify -debug-pass-manager \
; RUN: -pgo-kind=pgo-instr-use-pipeline -profile-file='%t.profdata' \
; RUN: -passes='thinlto-pre-link<O1>,name-anon-globals' -S %s 2>&1 \
@@ -52,7 +52,6 @@
; CHECK-O-NEXT: Running pass: LowerExpectIntrinsicPass
; CHECK-O3-NEXT: Running pass: CallSiteSplittingPass
; CHECK-O-NEXT: Finished {{.*}}Function pass manager run.
-; CHECK-O-NEXT: Running pass: AttributorPass
; CHECK-O-NEXT: Running pass: IPSCCPPass
; CHECK-O-NEXT: Running pass: CalledValuePropagationPass
; CHECK-O-NEXT: Running pass: GlobalOptPass
@@ -106,7 +105,6 @@
; CHECK-O-NEXT: Running analysis: OuterAnalysisManagerProxy<{{.*}}LazyCallGraph::SCC{{.*}}>
; CHECK-O-NEXT: Starting CGSCC pass manager run.
; CHECK-O-NEXT: Running pass: InlinerPass
-; CHECK-O-NEXT: Running pass: AttributorCGSCCPass
; CHECK-O-NEXT: Running pass: PostOrderFunctionAttrsPass
; CHECK-O-NEXT: Running analysis: AAManager on foo
; CHECK-O3-NEXT: Running pass: ArgumentPromotionPass
diff --git a/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
index 30a50c3fb5ca..a502654dc831 100644
--- a/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
+++ b/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
@@ -59,7 +59,6 @@
; CHECK-O-NEXT: Running analysis: ProfileSummaryAnalysis
; CHECK-O-NEXT: Running analysis: CallGraphAnalysis
; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}ProfileSummaryAnalysis
-; CHECK-O-NEXT: Running pass: AttributorPass
; CHECK-O-NEXT: Running pass: IPSCCPPass
; CHECK-O-NEXT: Running pass: CalledValuePropagationPass
; CHECK-O-NEXT: Running pass: GlobalOptPass
@@ -86,7 +85,6 @@
; CHECK-O-NEXT: Running analysis: OuterAnalysisManagerProxy<{{.*}}LazyCallGraph::SCC{{.*}}>
; CHECK-O-NEXT: Starting CGSCC pass manager run.
; CHECK-O-NEXT: Running pass: InlinerPass
-; CHECK-O-NEXT: Running pass: AttributorCGSCCPass
; CHECK-O-NEXT: Running pass: PostOrderFunctionAttrsPass
; CHECK-O3-NEXT: Running pass: ArgumentPromotionPass
; CHECK-O2-NEXT: Running pass: OpenMPOptPass
diff --git a/llvm/test/Other/opt-O2-pipeline.ll b/llvm/test/Other/opt-O2-pipeline.ll
index dbed460101b8..ffb3727dd249 100644
--- a/llvm/test/Other/opt-O2-pipeline.ll
+++ b/llvm/test/Other/opt-O2-pipeline.ll
@@ -22,14 +22,13 @@
; CHECK-NEXT: Target Library Information
; CHECK-NEXT: Target Transform Information
; Target Pass Configuration
-; CHECK: Type-Based Alias Analysis
+; CHECK: Type-Based Alias Analysis
; CHECK-NEXT: Scoped NoAlias Alias Analysis
; CHECK-NEXT: Assumption Cache Tracker
; CHECK-NEXT: Profile summary info
; CHECK-NEXT: ModulePass Manager
; CHECK-NEXT: Force set function attributes
; CHECK-NEXT: Infer set function attributes
-; CHECK-NEXT: Deduce and propagate attributes
; CHECK-NEXT: Interprocedural Sparse Conditional Constant Propagation
; CHECK-NEXT: FunctionPass Manager
; CHECK-NEXT: Dominator Tree Construction
@@ -59,7 +58,6 @@
; CHECK-NEXT: Call Graph SCC Pass Manager
; CHECK-NEXT: Remove unused exception handling info
; CHECK-NEXT: Function Integration/Inlining
-; CHECK-NEXT: Deduce and propagate attributes (CGSCC pass)
; CHECK-NEXT: OpenMP specific optimizations
; CHECK-NEXT: Deduce function attributes
; CHECK-NEXT: FunctionPass Manager
diff --git a/llvm/test/Other/opt-O3-pipeline.ll b/llvm/test/Other/opt-O3-pipeline.ll
index db8e5f94a7c4..d74e381f886c 100644
--- a/llvm/test/Other/opt-O3-pipeline.ll
+++ b/llvm/test/Other/opt-O3-pipeline.ll
@@ -29,7 +29,6 @@
; CHECK-NEXT: ModulePass Manager
; CHECK-NEXT: Force set function attributes
; CHECK-NEXT: Infer set function attributes
-; CHECK-NEXT: Deduce and propagate attributes
; CHECK-NEXT: FunctionPass Manager
; CHECK-NEXT: Dominator Tree Construction
; CHECK-NEXT: Call-site splitting
@@ -62,7 +61,6 @@
; CHECK-NEXT: Call Graph SCC Pass Manager
; CHECK-NEXT: Remove unused exception handling info
; CHECK-NEXT: Function Integration/Inlining
-; CHECK-NEXT: Deduce and propagate attributes (CGSCC pass)
; CHECK-NEXT: OpenMP specific optimizations
; CHECK-NEXT: Deduce function attributes
; CHECK-NEXT: Promote 'by reference' arguments to scalars
diff --git a/llvm/test/Other/opt-Os-pipeline.ll b/llvm/test/Other/opt-Os-pipeline.ll
index 4795af13de73..64e22add64cb 100644
--- a/llvm/test/Other/opt-Os-pipeline.ll
+++ b/llvm/test/Other/opt-Os-pipeline.ll
@@ -29,7 +29,6 @@
; CHECK-NEXT: ModulePass Manager
; CHECK-NEXT: Force set function attributes
; CHECK-NEXT: Infer set function attributes
-; CHECK-NEXT: Deduce and propagate attributes
; CHECK-NEXT: Interprocedural Sparse Conditional Constant Propagation
; CHECK-NEXT: FunctionPass Manager
; CHECK-NEXT: Dominator Tree Construction
@@ -59,7 +58,6 @@
; CHECK-NEXT: Call Graph SCC Pass Manager
; CHECK-NEXT: Remove unused exception handling info
; CHECK-NEXT: Function Integration/Inlining
-; CHECK-NEXT: Deduce and propagate attributes (CGSCC pass)
; CHECK-NEXT: OpenMP specific optimizations
; CHECK-NEXT: Deduce function attributes
; CHECK-NEXT: FunctionPass Manager
diff --git a/llvm/test/Other/pass-pipelines.ll b/llvm/test/Other/pass-pipelines.ll
index 718ca46e2ed2..620325ec1d5e 100644
--- a/llvm/test/Other/pass-pipelines.ll
+++ b/llvm/test/Other/pass-pipelines.ll
@@ -46,7 +46,6 @@
; CHECK-O2-NEXT: Call Graph SCC Pass Manager
; CHECK-O2-NEXT: Remove unused exception handling info
; CHECK-O2-NEXT: Function Integration/Inlining
-; CHECK-O2-NEXT: Deduce and propagate attributes (CGSCC pass)
; CHECK-O2-NEXT: OpenMP specific optimizations
; CHECK-O2-NEXT: Deduce function attributes
; Next up is the main function pass pipeline. It shouldn't be split up and
diff --git a/llvm/test/Transforms/Attributor/ArgumentPromotion/invalidation.ll b/llvm/test/Transforms/Attributor/ArgumentPromotion/invalidation.ll
index e49cc7e2ed73..5f6e9d10888e 100644
--- a/llvm/test/Transforms/Attributor/ArgumentPromotion/invalidation.ll
+++ b/llvm/test/Transforms/Attributor/ArgumentPromotion/invalidation.ll
@@ -12,10 +12,9 @@
@G = constant i32 0
define internal i32 @a(i32* %x) {
-; CHECK-LABEL: define {{[^@]+}}@a
-; CHECK-SAME: (i32* [[X:%.*]])
+; CHECK-LABEL: define {{[^@]+}}@a()
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[V:%.*]] = load i32, i32* [[X]]
+; CHECK-NEXT: [[V:%.*]] = load i32, i32* @G, align 4
; CHECK-NEXT: ret i32 [[V]]
;
entry:
@@ -26,7 +25,7 @@ entry:
define i32 @b() {
; CHECK-LABEL: define {{[^@]+}}@b()
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[V:%.*]] = call i32 @a(i32* @G)
+; CHECK-NEXT: [[V:%.*]] = call i32 @a()
; CHECK-NEXT: ret i32 [[V]]
;
entry:
@@ -37,7 +36,7 @@ entry:
define i32 @c() {
; CHECK-LABEL: define {{[^@]+}}@c()
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[V1:%.*]] = call i32 @a(i32* @G)
+; CHECK-NEXT: [[V1:%.*]] = call i32 @a()
; CHECK-NEXT: [[V2:%.*]] = call i32 @b()
; CHECK-NEXT: [[RESULT:%.*]] = add i32 [[V1]], [[V2]]
; CHECK-NEXT: ret i32 [[RESULT]]
More information about the llvm-commits
mailing list