[PM] Add (very skeletal) support to opt for running the new pass
manager. I cannot emphasize enough that this is a WIP. =] I expect it
to change a great deal as things stabilize, but I think its really
important to get *some* functionality here so that the infrastructure
can be tested more traditionally from the commandline.
The current design is looking something like this:
./bin/opt -passes='module(pass_a,pass_b,function(pass_c,pass_d))'
So rather than custom-parsed flags, there is a single flag with a string
argument that is parsed into the pass pipeline structure. This makes it
really easy to have nice structural properties that are very explicit.
There is one obvious and important shortcut. You can start off the
pipeline with a pass, and the minimal context of pass managers will be
built around the entire specified pipeline. This makes the common case
for tests super easy:
./bin/opt -passes=instcombine,sroa,gvn
But this won't introduce any of the complexity of the fully inferred old
system -- we only ever do this for the *entire* argument, and we only
look at the first pass. If the other passes don't fit in the pass
manager selected it is a hard error.
The other interesting aspect here is that I'm not relying on any
registration facilities. Such facilities may be unavoidable for
supporting plugins, but I have alternative ideas for plugins that I'd
like to try first. My plan is essentially to build everything without
registration until we hit an absolute requirement.
Instead of registration of pass names, there will be a library dedicated
to parsing pass names and the pass pipeline strings described above.
Currently, this is directly embedded into opt for simplicity as it is
very early, but I plan to eventually pull this into a library that opt,
bugpoint, and even Clang can depend on. It should end up as a good home
for things like the existing PassManagerBuilder as well.
There are a bunch of FIXMEs in the code for the parts of this that are
just stubbed out to make the patch more incremental. A quick list of
what's coming up directly after this:
- Support for function passes and building the structured nesting.
- Support for printing the pass structure, and FileCheck tests of all of
this code.
- The .def-file based pass name parsing.
- IR priting passes and the corresponding tests.
Some obvious things that I'm not going to do right now, but am
definitely planning on as the pass manager work gets a bit further:
- Pull the parsing into library, including the builders.
- Thread the rest of the target stuff into the new pass manager.
- Wire support for the new pass manager up to llc.
- Plugin support.
Some things that I'd like to have, but are significantly lower on my
priority list. I'll get to these eventually, but they may also be places
where others want to contribute:
- Adding nice error reporting for broken pass pipeline descriptions.
- Typo-correction for pass names.
llvm-svn: 198998
2014-01-11 09:16:35 +01:00
|
|
|
//===- NewPMDriver.cpp - Driver for opt with new PM -----------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// \file
|
|
|
|
///
|
|
|
|
/// This file is just a split of the code that logically belongs in opt.cpp but
|
|
|
|
/// that includes the new pass manager headers.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "NewPMDriver.h"
|
2018-09-24 18:08:15 +02:00
|
|
|
#include "Debugify.h"
|
2018-02-15 22:14:36 +01:00
|
|
|
#include "PassPrinters.h"
|
[PM] Add (very skeletal) support to opt for running the new pass
manager. I cannot emphasize enough that this is a WIP. =] I expect it
to change a great deal as things stabilize, but I think its really
important to get *some* functionality here so that the infrastructure
can be tested more traditionally from the commandline.
The current design is looking something like this:
./bin/opt -passes='module(pass_a,pass_b,function(pass_c,pass_d))'
So rather than custom-parsed flags, there is a single flag with a string
argument that is parsed into the pass pipeline structure. This makes it
really easy to have nice structural properties that are very explicit.
There is one obvious and important shortcut. You can start off the
pipeline with a pass, and the minimal context of pass managers will be
built around the entire specified pipeline. This makes the common case
for tests super easy:
./bin/opt -passes=instcombine,sroa,gvn
But this won't introduce any of the complexity of the fully inferred old
system -- we only ever do this for the *entire* argument, and we only
look at the first pass. If the other passes don't fit in the pass
manager selected it is a hard error.
The other interesting aspect here is that I'm not relying on any
registration facilities. Such facilities may be unavoidable for
supporting plugins, but I have alternative ideas for plugins that I'd
like to try first. My plan is essentially to build everything without
registration until we hit an absolute requirement.
Instead of registration of pass names, there will be a library dedicated
to parsing pass names and the pass pipeline strings described above.
Currently, this is directly embedded into opt for simplicity as it is
very early, but I plan to eventually pull this into a library that opt,
bugpoint, and even Clang can depend on. It should end up as a good home
for things like the existing PassManagerBuilder as well.
There are a bunch of FIXMEs in the code for the parts of this that are
just stubbed out to make the patch more incremental. A quick list of
what's coming up directly after this:
- Support for function passes and building the structured nesting.
- Support for printing the pass structure, and FileCheck tests of all of
this code.
- The .def-file based pass name parsing.
- IR priting passes and the corresponding tests.
Some obvious things that I'm not going to do right now, but am
definitely planning on as the pass manager work gets a bit further:
- Pull the parsing into library, including the builders.
- Thread the rest of the target stuff into the new pass manager.
- Wire support for the new pass manager up to llc.
- Plugin support.
Some things that I'd like to have, but are significantly lower on my
priority list. I'll get to these eventually, but they may also be places
where others want to contribute:
- Adding nice error reporting for broken pass pipeline descriptions.
- Typo-correction for pass names.
llvm-svn: 198998
2014-01-11 09:16:35 +01:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2016-02-18 10:45:17 +01:00
|
|
|
#include "llvm/Analysis/AliasAnalysis.h"
|
2014-04-21 13:12:00 +02:00
|
|
|
#include "llvm/Analysis/CGSCCPassManager.h"
|
2014-01-13 08:38:24 +01:00
|
|
|
#include "llvm/Bitcode/BitcodeWriterPass.h"
|
2018-04-30 16:59:11 +02:00
|
|
|
#include "llvm/Config/llvm-config.h"
|
2015-01-14 11:19:28 +01:00
|
|
|
#include "llvm/IR/Dominators.h"
|
2014-01-13 06:16:45 +01:00
|
|
|
#include "llvm/IR/IRPrintingPasses.h"
|
[PM] Add (very skeletal) support to opt for running the new pass
manager. I cannot emphasize enough that this is a WIP. =] I expect it
to change a great deal as things stabilize, but I think its really
important to get *some* functionality here so that the infrastructure
can be tested more traditionally from the commandline.
The current design is looking something like this:
./bin/opt -passes='module(pass_a,pass_b,function(pass_c,pass_d))'
So rather than custom-parsed flags, there is a single flag with a string
argument that is parsed into the pass pipeline structure. This makes it
really easy to have nice structural properties that are very explicit.
There is one obvious and important shortcut. You can start off the
pipeline with a pass, and the minimal context of pass managers will be
built around the entire specified pipeline. This makes the common case
for tests super easy:
./bin/opt -passes=instcombine,sroa,gvn
But this won't introduce any of the complexity of the fully inferred old
system -- we only ever do this for the *entire* argument, and we only
look at the first pass. If the other passes don't fit in the pass
manager selected it is a hard error.
The other interesting aspect here is that I'm not relying on any
registration facilities. Such facilities may be unavoidable for
supporting plugins, but I have alternative ideas for plugins that I'd
like to try first. My plan is essentially to build everything without
registration until we hit an absolute requirement.
Instead of registration of pass names, there will be a library dedicated
to parsing pass names and the pass pipeline strings described above.
Currently, this is directly embedded into opt for simplicity as it is
very early, but I plan to eventually pull this into a library that opt,
bugpoint, and even Clang can depend on. It should end up as a good home
for things like the existing PassManagerBuilder as well.
There are a bunch of FIXMEs in the code for the parts of this that are
just stubbed out to make the patch more incremental. A quick list of
what's coming up directly after this:
- Support for function passes and building the structured nesting.
- Support for printing the pass structure, and FileCheck tests of all of
this code.
- The .def-file based pass name parsing.
- IR priting passes and the corresponding tests.
Some obvious things that I'm not going to do right now, but am
definitely planning on as the pass manager work gets a bit further:
- Pull the parsing into library, including the builders.
- Thread the rest of the target stuff into the new pass manager.
- Wire support for the new pass manager up to llc.
- Plugin support.
Some things that I'd like to have, but are significantly lower on my
priority list. I'll get to these eventually, but they may also be places
where others want to contribute:
- Adding nice error reporting for broken pass pipeline descriptions.
- Typo-correction for pass names.
llvm-svn: 198998
2014-01-11 09:16:35 +01:00
|
|
|
#include "llvm/IR/LLVMContext.h"
|
|
|
|
#include "llvm/IR/Module.h"
|
|
|
|
#include "llvm/IR/PassManager.h"
|
2014-01-20 12:34:08 +01:00
|
|
|
#include "llvm/IR/Verifier.h"
|
2015-03-07 10:02:36 +01:00
|
|
|
#include "llvm/Passes/PassBuilder.h"
|
2018-04-05 17:04:13 +02:00
|
|
|
#include "llvm/Passes/PassPlugin.h"
|
2018-09-24 18:08:15 +02:00
|
|
|
#include "llvm/Passes/StandardInstrumentations.h"
|
[PM] Add (very skeletal) support to opt for running the new pass
manager. I cannot emphasize enough that this is a WIP. =] I expect it
to change a great deal as things stabilize, but I think its really
important to get *some* functionality here so that the infrastructure
can be tested more traditionally from the commandline.
The current design is looking something like this:
./bin/opt -passes='module(pass_a,pass_b,function(pass_c,pass_d))'
So rather than custom-parsed flags, there is a single flag with a string
argument that is parsed into the pass pipeline structure. This makes it
really easy to have nice structural properties that are very explicit.
There is one obvious and important shortcut. You can start off the
pipeline with a pass, and the minimal context of pass managers will be
built around the entire specified pipeline. This makes the common case
for tests super easy:
./bin/opt -passes=instcombine,sroa,gvn
But this won't introduce any of the complexity of the fully inferred old
system -- we only ever do this for the *entire* argument, and we only
look at the first pass. If the other passes don't fit in the pass
manager selected it is a hard error.
The other interesting aspect here is that I'm not relying on any
registration facilities. Such facilities may be unavoidable for
supporting plugins, but I have alternative ideas for plugins that I'd
like to try first. My plan is essentially to build everything without
registration until we hit an absolute requirement.
Instead of registration of pass names, there will be a library dedicated
to parsing pass names and the pass pipeline strings described above.
Currently, this is directly embedded into opt for simplicity as it is
very early, but I plan to eventually pull this into a library that opt,
bugpoint, and even Clang can depend on. It should end up as a good home
for things like the existing PassManagerBuilder as well.
There are a bunch of FIXMEs in the code for the parts of this that are
just stubbed out to make the patch more incremental. A quick list of
what's coming up directly after this:
- Support for function passes and building the structured nesting.
- Support for printing the pass structure, and FileCheck tests of all of
this code.
- The .def-file based pass name parsing.
- IR priting passes and the corresponding tests.
Some obvious things that I'm not going to do right now, but am
definitely planning on as the pass manager work gets a bit further:
- Pull the parsing into library, including the builders.
- Thread the rest of the target stuff into the new pass manager.
- Wire support for the new pass manager up to llc.
- Plugin support.
Some things that I'd like to have, but are significantly lower on my
priority list. I'll get to these eventually, but they may also be places
where others want to contribute:
- Adding nice error reporting for broken pass pipeline descriptions.
- Typo-correction for pass names.
llvm-svn: 198998
2014-01-11 09:16:35 +01:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2014-01-13 06:16:45 +01:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
[PM] Add (very skeletal) support to opt for running the new pass
manager. I cannot emphasize enough that this is a WIP. =] I expect it
to change a great deal as things stabilize, but I think its really
important to get *some* functionality here so that the infrastructure
can be tested more traditionally from the commandline.
The current design is looking something like this:
./bin/opt -passes='module(pass_a,pass_b,function(pass_c,pass_d))'
So rather than custom-parsed flags, there is a single flag with a string
argument that is parsed into the pass pipeline structure. This makes it
really easy to have nice structural properties that are very explicit.
There is one obvious and important shortcut. You can start off the
pipeline with a pass, and the minimal context of pass managers will be
built around the entire specified pipeline. This makes the common case
for tests super easy:
./bin/opt -passes=instcombine,sroa,gvn
But this won't introduce any of the complexity of the fully inferred old
system -- we only ever do this for the *entire* argument, and we only
look at the first pass. If the other passes don't fit in the pass
manager selected it is a hard error.
The other interesting aspect here is that I'm not relying on any
registration facilities. Such facilities may be unavoidable for
supporting plugins, but I have alternative ideas for plugins that I'd
like to try first. My plan is essentially to build everything without
registration until we hit an absolute requirement.
Instead of registration of pass names, there will be a library dedicated
to parsing pass names and the pass pipeline strings described above.
Currently, this is directly embedded into opt for simplicity as it is
very early, but I plan to eventually pull this into a library that opt,
bugpoint, and even Clang can depend on. It should end up as a good home
for things like the existing PassManagerBuilder as well.
There are a bunch of FIXMEs in the code for the parts of this that are
just stubbed out to make the patch more incremental. A quick list of
what's coming up directly after this:
- Support for function passes and building the structured nesting.
- Support for printing the pass structure, and FileCheck tests of all of
this code.
- The .def-file based pass name parsing.
- IR priting passes and the corresponding tests.
Some obvious things that I'm not going to do right now, but am
definitely planning on as the pass manager work gets a bit further:
- Pull the parsing into library, including the builders.
- Thread the rest of the target stuff into the new pass manager.
- Wire support for the new pass manager up to llc.
- Plugin support.
Some things that I'd like to have, but are significantly lower on my
priority list. I'll get to these eventually, but they may also be places
where others want to contribute:
- Adding nice error reporting for broken pass pipeline descriptions.
- Typo-correction for pass names.
llvm-svn: 198998
2014-01-11 09:16:35 +01:00
|
|
|
#include "llvm/Support/ToolOutputFile.h"
|
2015-02-01 11:11:22 +01:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2017-06-01 03:02:12 +02:00
|
|
|
#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
|
2017-01-11 10:43:56 +01:00
|
|
|
#include "llvm/Transforms/Scalar/LoopPassManager.h"
|
[PM] Add (very skeletal) support to opt for running the new pass
manager. I cannot emphasize enough that this is a WIP. =] I expect it
to change a great deal as things stabilize, but I think its really
important to get *some* functionality here so that the infrastructure
can be tested more traditionally from the commandline.
The current design is looking something like this:
./bin/opt -passes='module(pass_a,pass_b,function(pass_c,pass_d))'
So rather than custom-parsed flags, there is a single flag with a string
argument that is parsed into the pass pipeline structure. This makes it
really easy to have nice structural properties that are very explicit.
There is one obvious and important shortcut. You can start off the
pipeline with a pass, and the minimal context of pass managers will be
built around the entire specified pipeline. This makes the common case
for tests super easy:
./bin/opt -passes=instcombine,sroa,gvn
But this won't introduce any of the complexity of the fully inferred old
system -- we only ever do this for the *entire* argument, and we only
look at the first pass. If the other passes don't fit in the pass
manager selected it is a hard error.
The other interesting aspect here is that I'm not relying on any
registration facilities. Such facilities may be unavoidable for
supporting plugins, but I have alternative ideas for plugins that I'd
like to try first. My plan is essentially to build everything without
registration until we hit an absolute requirement.
Instead of registration of pass names, there will be a library dedicated
to parsing pass names and the pass pipeline strings described above.
Currently, this is directly embedded into opt for simplicity as it is
very early, but I plan to eventually pull this into a library that opt,
bugpoint, and even Clang can depend on. It should end up as a good home
for things like the existing PassManagerBuilder as well.
There are a bunch of FIXMEs in the code for the parts of this that are
just stubbed out to make the patch more incremental. A quick list of
what's coming up directly after this:
- Support for function passes and building the structured nesting.
- Support for printing the pass structure, and FileCheck tests of all of
this code.
- The .def-file based pass name parsing.
- IR priting passes and the corresponding tests.
Some obvious things that I'm not going to do right now, but am
definitely planning on as the pass manager work gets a bit further:
- Pull the parsing into library, including the builders.
- Thread the rest of the target stuff into the new pass manager.
- Wire support for the new pass manager up to llc.
- Plugin support.
Some things that I'd like to have, but are significantly lower on my
priority list. I'll get to these eventually, but they may also be places
where others want to contribute:
- Adding nice error reporting for broken pass pipeline descriptions.
- Typo-correction for pass names.
llvm-svn: 198998
2014-01-11 09:16:35 +01:00
|
|
|
|
|
|
|
using namespace llvm;
|
2014-01-13 04:08:40 +01:00
|
|
|
using namespace opt_tool;
|
[PM] Add (very skeletal) support to opt for running the new pass
manager. I cannot emphasize enough that this is a WIP. =] I expect it
to change a great deal as things stabilize, but I think its really
important to get *some* functionality here so that the infrastructure
can be tested more traditionally from the commandline.
The current design is looking something like this:
./bin/opt -passes='module(pass_a,pass_b,function(pass_c,pass_d))'
So rather than custom-parsed flags, there is a single flag with a string
argument that is parsed into the pass pipeline structure. This makes it
really easy to have nice structural properties that are very explicit.
There is one obvious and important shortcut. You can start off the
pipeline with a pass, and the minimal context of pass managers will be
built around the entire specified pipeline. This makes the common case
for tests super easy:
./bin/opt -passes=instcombine,sroa,gvn
But this won't introduce any of the complexity of the fully inferred old
system -- we only ever do this for the *entire* argument, and we only
look at the first pass. If the other passes don't fit in the pass
manager selected it is a hard error.
The other interesting aspect here is that I'm not relying on any
registration facilities. Such facilities may be unavoidable for
supporting plugins, but I have alternative ideas for plugins that I'd
like to try first. My plan is essentially to build everything without
registration until we hit an absolute requirement.
Instead of registration of pass names, there will be a library dedicated
to parsing pass names and the pass pipeline strings described above.
Currently, this is directly embedded into opt for simplicity as it is
very early, but I plan to eventually pull this into a library that opt,
bugpoint, and even Clang can depend on. It should end up as a good home
for things like the existing PassManagerBuilder as well.
There are a bunch of FIXMEs in the code for the parts of this that are
just stubbed out to make the patch more incremental. A quick list of
what's coming up directly after this:
- Support for function passes and building the structured nesting.
- Support for printing the pass structure, and FileCheck tests of all of
this code.
- The .def-file based pass name parsing.
- IR priting passes and the corresponding tests.
Some obvious things that I'm not going to do right now, but am
definitely planning on as the pass manager work gets a bit further:
- Pull the parsing into library, including the builders.
- Thread the rest of the target stuff into the new pass manager.
- Wire support for the new pass manager up to llc.
- Plugin support.
Some things that I'd like to have, but are significantly lower on my
priority list. I'll get to these eventually, but they may also be places
where others want to contribute:
- Adding nice error reporting for broken pass pipeline descriptions.
- Typo-correction for pass names.
llvm-svn: 198998
2014-01-11 09:16:35 +01:00
|
|
|
|
2015-01-13 23:42:38 +01:00
|
|
|
static cl::opt<bool>
|
|
|
|
DebugPM("debug-pass-manager", cl::Hidden,
|
|
|
|
cl::desc("Print pass management debugging information"));
|
|
|
|
|
2018-04-05 17:04:13 +02:00
|
|
|
static cl::list<std::string>
|
|
|
|
PassPlugins("load-pass-plugin",
|
|
|
|
cl::desc("Load passes from plugin library"));
|
|
|
|
|
2016-02-18 10:45:17 +01:00
|
|
|
// This flag specifies a textual description of the alias analysis pipeline to
|
|
|
|
// use when querying for aliasing information. It only works in concert with
|
|
|
|
// the "passes" flag above.
|
|
|
|
static cl::opt<std::string>
|
|
|
|
AAPipeline("aa-pipeline",
|
|
|
|
cl::desc("A textual description of the alias analysis "
|
|
|
|
"pipeline for handling managed aliasing queries"),
|
|
|
|
cl::Hidden);
|
|
|
|
|
[PM] Enable registration of out-of-tree passes with PassBuilder
Summary:
This patch adds a callback registration API to the PassBuilder,
enabling registering out-of-tree passes with it.
Through the Callback API, callers may register callbacks with the
various stages at which passes are added into pass managers, including
parsing of a pass pipeline as well as at extension points within the
default -O pipelines.
Registering utilities like `require<>` and `invalidate<>` needs to be
handled manually by the caller, but a helper is provided.
Additionally, adding passes at pipeline extension points is exposed
through the opt tool. This patch adds a `-passes-ep-X` commandline
option for every extension point X, which opt parses into pipelines
inserted into that extension point.
Reviewers: chandlerc
Reviewed By: chandlerc
Subscribers: lksbhm, grosser, davide, mehdi_amini, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D33464
llvm-svn: 307532
2017-07-10 12:57:55 +02:00
|
|
|
/// {{@ These options accept textual pipeline descriptions which will be
|
|
|
|
/// inserted into default pipelines at the respective extension points
|
|
|
|
static cl::opt<std::string> PeepholeEPPipeline(
|
|
|
|
"passes-ep-peephole",
|
|
|
|
cl::desc("A textual description of the function pass pipeline inserted at "
|
|
|
|
"the Peephole extension points into default pipelines"),
|
|
|
|
cl::Hidden);
|
|
|
|
static cl::opt<std::string> LateLoopOptimizationsEPPipeline(
|
|
|
|
"passes-ep-late-loop-optimizations",
|
|
|
|
cl::desc(
|
|
|
|
"A textual description of the loop pass pipeline inserted at "
|
|
|
|
"the LateLoopOptimizations extension point into default pipelines"),
|
|
|
|
cl::Hidden);
|
|
|
|
static cl::opt<std::string> LoopOptimizerEndEPPipeline(
|
|
|
|
"passes-ep-loop-optimizer-end",
|
|
|
|
cl::desc("A textual description of the loop pass pipeline inserted at "
|
|
|
|
"the LoopOptimizerEnd extension point into default pipelines"),
|
|
|
|
cl::Hidden);
|
|
|
|
static cl::opt<std::string> ScalarOptimizerLateEPPipeline(
|
|
|
|
"passes-ep-scalar-optimizer-late",
|
|
|
|
cl::desc("A textual description of the function pass pipeline inserted at "
|
|
|
|
"the ScalarOptimizerLate extension point into default pipelines"),
|
|
|
|
cl::Hidden);
|
|
|
|
static cl::opt<std::string> CGSCCOptimizerLateEPPipeline(
|
|
|
|
"passes-ep-cgscc-optimizer-late",
|
|
|
|
cl::desc("A textual description of the cgscc pass pipeline inserted at "
|
|
|
|
"the CGSCCOptimizerLate extension point into default pipelines"),
|
|
|
|
cl::Hidden);
|
|
|
|
static cl::opt<std::string> VectorizerStartEPPipeline(
|
|
|
|
"passes-ep-vectorizer-start",
|
|
|
|
cl::desc("A textual description of the function pass pipeline inserted at "
|
|
|
|
"the VectorizerStart extension point into default pipelines"),
|
|
|
|
cl::Hidden);
|
2018-01-23 02:25:20 +01:00
|
|
|
static cl::opt<std::string> PipelineStartEPPipeline(
|
|
|
|
"passes-ep-pipeline-start",
|
|
|
|
cl::desc("A textual description of the function pass pipeline inserted at "
|
|
|
|
"the PipelineStart extension point into default pipelines"),
|
|
|
|
cl::Hidden);
|
2018-11-12 12:17:07 +01:00
|
|
|
static cl::opt<std::string> OptimizerLastEPPipeline(
|
|
|
|
"passes-ep-optimizer-last",
|
|
|
|
cl::desc("A textual description of the function pass pipeline inserted at "
|
|
|
|
"the OptimizerLast extension point into default pipelines"),
|
|
|
|
cl::Hidden);
|
|
|
|
|
2017-07-26 04:00:43 +02:00
|
|
|
enum PGOKind { NoPGO, InstrGen, InstrUse, SampleUse };
|
|
|
|
static cl::opt<PGOKind> PGOKindFlag(
|
|
|
|
"pgo-kind", cl::init(NoPGO), cl::Hidden,
|
|
|
|
cl::desc("The kind of profile guided optimization"),
|
|
|
|
cl::values(clEnumValN(NoPGO, "nopgo", "Do not use PGO."),
|
|
|
|
clEnumValN(InstrGen, "new-pm-pgo-instr-gen-pipeline",
|
|
|
|
"Instrument the IR to generate profile."),
|
|
|
|
clEnumValN(InstrUse, "new-pm-pgo-instr-use-pipeline",
|
|
|
|
"Use instrumented profile to guide PGO."),
|
|
|
|
clEnumValN(SampleUse, "new-pm-pgo-sample-use-pipeline",
|
|
|
|
"Use sampled profile to guide PGO.")));
|
|
|
|
static cl::opt<std::string> ProfileFile(
|
|
|
|
"profile-file", cl::desc("Path to the profile."), cl::Hidden);
|
Add a flag to remap manglings when reading profile data information.
This can be used to preserve profiling information across codebase
changes that have widespread impact on mangled names, but across which
most profiling data should still be usable. For example, when switching
from libstdc++ to libc++, or from the old libstdc++ ABI to the new ABI,
or even from a 32-bit to a 64-bit build.
The user can provide a remapping file specifying parts of mangled names
that should be treated as equivalent (eg, std::__1 should be treated as
equivalent to std::__cxx11), and profile data will be treated as
applying to a particular function if its name is equivalent to the name
of a function in the profile data under the provided equivalences. See
the documentation change for a description of how this is configured.
Remapping is supported for both sample-based profiling and instruction
profiling. We do not support remapping indirect branch target
information, but all other profile data should be remapped
appropriately.
Support is only added for the new pass manager. If someone wants to also
add support for this for the old pass manager, doing so should be
straightforward.
This is the LLVM side of Clang r344199.
Reviewers: davidxl, tejohnson, dlj, erik.pilkington
Subscribers: mehdi_amini, steven_wu, dexonsmith, llvm-commits
Differential Revision: https://reviews.llvm.org/D51249
llvm-svn: 344200
2018-10-11 01:13:47 +02:00
|
|
|
static cl::opt<std::string>
|
|
|
|
ProfileRemappingFile("profile-remapping-file",
|
|
|
|
cl::desc("Path to the profile remapping file."),
|
|
|
|
cl::Hidden);
|
2017-07-26 17:01:20 +02:00
|
|
|
static cl::opt<bool> DebugInfoForProfiling(
|
|
|
|
"new-pm-debug-info-for-profiling", cl::init(false), cl::Hidden,
|
|
|
|
cl::desc("Emit special debug info to enable PGO profile generation."));
|
[PM] Enable registration of out-of-tree passes with PassBuilder
Summary:
This patch adds a callback registration API to the PassBuilder,
enabling registering out-of-tree passes with it.
Through the Callback API, callers may register callbacks with the
various stages at which passes are added into pass managers, including
parsing of a pass pipeline as well as at extension points within the
default -O pipelines.
Registering utilities like `require<>` and `invalidate<>` needs to be
handled manually by the caller, but a helper is provided.
Additionally, adding passes at pipeline extension points is exposed
through the opt tool. This patch adds a `-passes-ep-X` commandline
option for every extension point X, which opt parses into pipelines
inserted into that extension point.
Reviewers: chandlerc
Reviewed By: chandlerc
Subscribers: lksbhm, grosser, davide, mehdi_amini, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D33464
llvm-svn: 307532
2017-07-10 12:57:55 +02:00
|
|
|
/// @}}
|
|
|
|
|
2017-07-11 13:17:44 +02:00
|
|
|
template <typename PassManagerT>
|
2018-10-17 12:36:23 +02:00
|
|
|
bool tryParsePipelineText(PassBuilder &PB,
|
|
|
|
const cl::opt<std::string> &PipelineOpt) {
|
|
|
|
if (PipelineOpt.empty())
|
2017-07-11 13:17:44 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// Verify the pipeline is parseable:
|
|
|
|
PassManagerT PM;
|
2018-10-17 12:36:23 +02:00
|
|
|
if (auto Err = PB.parsePassPipeline(PM, PipelineOpt)) {
|
|
|
|
errs() << "Could not parse -" << PipelineOpt.ArgStr
|
|
|
|
<< " pipeline: " << toString(std::move(Err))
|
|
|
|
<< "... I'm going to ignore it.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2017-07-11 13:17:44 +02:00
|
|
|
}
|
|
|
|
|
[PM] Enable registration of out-of-tree passes with PassBuilder
Summary:
This patch adds a callback registration API to the PassBuilder,
enabling registering out-of-tree passes with it.
Through the Callback API, callers may register callbacks with the
various stages at which passes are added into pass managers, including
parsing of a pass pipeline as well as at extension points within the
default -O pipelines.
Registering utilities like `require<>` and `invalidate<>` needs to be
handled manually by the caller, but a helper is provided.
Additionally, adding passes at pipeline extension points is exposed
through the opt tool. This patch adds a `-passes-ep-X` commandline
option for every extension point X, which opt parses into pipelines
inserted into that extension point.
Reviewers: chandlerc
Reviewed By: chandlerc
Subscribers: lksbhm, grosser, davide, mehdi_amini, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D33464
llvm-svn: 307532
2017-07-10 12:57:55 +02:00
|
|
|
/// If one of the EPPipeline command line options was given, register callbacks
|
|
|
|
/// for parsing and inserting the given pipeline
|
|
|
|
static void registerEPCallbacks(PassBuilder &PB, bool VerifyEachPass,
|
|
|
|
bool DebugLogging) {
|
2017-07-11 13:17:44 +02:00
|
|
|
if (tryParsePipelineText<FunctionPassManager>(PB, PeepholeEPPipeline))
|
2018-10-17 12:36:23 +02:00
|
|
|
PB.registerPeepholeEPCallback(
|
|
|
|
[&PB, VerifyEachPass, DebugLogging](
|
|
|
|
FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
|
|
|
|
ExitOnError Err("Unable to parse PeepholeEP pipeline: ");
|
|
|
|
Err(PB.parsePassPipeline(PM, PeepholeEPPipeline, VerifyEachPass,
|
|
|
|
DebugLogging));
|
|
|
|
});
|
2017-07-11 13:17:44 +02:00
|
|
|
if (tryParsePipelineText<LoopPassManager>(PB,
|
|
|
|
LateLoopOptimizationsEPPipeline))
|
[PM] Enable registration of out-of-tree passes with PassBuilder
Summary:
This patch adds a callback registration API to the PassBuilder,
enabling registering out-of-tree passes with it.
Through the Callback API, callers may register callbacks with the
various stages at which passes are added into pass managers, including
parsing of a pass pipeline as well as at extension points within the
default -O pipelines.
Registering utilities like `require<>` and `invalidate<>` needs to be
handled manually by the caller, but a helper is provided.
Additionally, adding passes at pipeline extension points is exposed
through the opt tool. This patch adds a `-passes-ep-X` commandline
option for every extension point X, which opt parses into pipelines
inserted into that extension point.
Reviewers: chandlerc
Reviewed By: chandlerc
Subscribers: lksbhm, grosser, davide, mehdi_amini, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D33464
llvm-svn: 307532
2017-07-10 12:57:55 +02:00
|
|
|
PB.registerLateLoopOptimizationsEPCallback(
|
2017-07-10 14:48:51 +02:00
|
|
|
[&PB, VerifyEachPass, DebugLogging](
|
|
|
|
LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
|
2018-10-17 12:36:23 +02:00
|
|
|
ExitOnError Err("Unable to parse LateLoopOptimizationsEP pipeline: ");
|
|
|
|
Err(PB.parsePassPipeline(PM, LateLoopOptimizationsEPPipeline,
|
|
|
|
VerifyEachPass, DebugLogging));
|
[PM] Enable registration of out-of-tree passes with PassBuilder
Summary:
This patch adds a callback registration API to the PassBuilder,
enabling registering out-of-tree passes with it.
Through the Callback API, callers may register callbacks with the
various stages at which passes are added into pass managers, including
parsing of a pass pipeline as well as at extension points within the
default -O pipelines.
Registering utilities like `require<>` and `invalidate<>` needs to be
handled manually by the caller, but a helper is provided.
Additionally, adding passes at pipeline extension points is exposed
through the opt tool. This patch adds a `-passes-ep-X` commandline
option for every extension point X, which opt parses into pipelines
inserted into that extension point.
Reviewers: chandlerc
Reviewed By: chandlerc
Subscribers: lksbhm, grosser, davide, mehdi_amini, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D33464
llvm-svn: 307532
2017-07-10 12:57:55 +02:00
|
|
|
});
|
2017-07-11 13:17:44 +02:00
|
|
|
if (tryParsePipelineText<LoopPassManager>(PB, LoopOptimizerEndEPPipeline))
|
2018-10-17 12:36:23 +02:00
|
|
|
PB.registerLoopOptimizerEndEPCallback(
|
|
|
|
[&PB, VerifyEachPass, DebugLogging](
|
|
|
|
LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
|
|
|
|
ExitOnError Err("Unable to parse LoopOptimizerEndEP pipeline: ");
|
|
|
|
Err(PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline,
|
|
|
|
VerifyEachPass, DebugLogging));
|
|
|
|
});
|
2017-07-11 13:17:44 +02:00
|
|
|
if (tryParsePipelineText<FunctionPassManager>(PB,
|
|
|
|
ScalarOptimizerLateEPPipeline))
|
[PM] Enable registration of out-of-tree passes with PassBuilder
Summary:
This patch adds a callback registration API to the PassBuilder,
enabling registering out-of-tree passes with it.
Through the Callback API, callers may register callbacks with the
various stages at which passes are added into pass managers, including
parsing of a pass pipeline as well as at extension points within the
default -O pipelines.
Registering utilities like `require<>` and `invalidate<>` needs to be
handled manually by the caller, but a helper is provided.
Additionally, adding passes at pipeline extension points is exposed
through the opt tool. This patch adds a `-passes-ep-X` commandline
option for every extension point X, which opt parses into pipelines
inserted into that extension point.
Reviewers: chandlerc
Reviewed By: chandlerc
Subscribers: lksbhm, grosser, davide, mehdi_amini, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D33464
llvm-svn: 307532
2017-07-10 12:57:55 +02:00
|
|
|
PB.registerScalarOptimizerLateEPCallback(
|
2017-07-10 14:48:51 +02:00
|
|
|
[&PB, VerifyEachPass, DebugLogging](
|
|
|
|
FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
|
2018-10-17 12:36:23 +02:00
|
|
|
ExitOnError Err("Unable to parse ScalarOptimizerLateEP pipeline: ");
|
|
|
|
Err(PB.parsePassPipeline(PM, ScalarOptimizerLateEPPipeline,
|
|
|
|
VerifyEachPass, DebugLogging));
|
[PM] Enable registration of out-of-tree passes with PassBuilder
Summary:
This patch adds a callback registration API to the PassBuilder,
enabling registering out-of-tree passes with it.
Through the Callback API, callers may register callbacks with the
various stages at which passes are added into pass managers, including
parsing of a pass pipeline as well as at extension points within the
default -O pipelines.
Registering utilities like `require<>` and `invalidate<>` needs to be
handled manually by the caller, but a helper is provided.
Additionally, adding passes at pipeline extension points is exposed
through the opt tool. This patch adds a `-passes-ep-X` commandline
option for every extension point X, which opt parses into pipelines
inserted into that extension point.
Reviewers: chandlerc
Reviewed By: chandlerc
Subscribers: lksbhm, grosser, davide, mehdi_amini, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D33464
llvm-svn: 307532
2017-07-10 12:57:55 +02:00
|
|
|
});
|
2017-07-11 13:17:44 +02:00
|
|
|
if (tryParsePipelineText<CGSCCPassManager>(PB, CGSCCOptimizerLateEPPipeline))
|
2018-10-17 12:36:23 +02:00
|
|
|
PB.registerCGSCCOptimizerLateEPCallback(
|
|
|
|
[&PB, VerifyEachPass, DebugLogging](
|
|
|
|
CGSCCPassManager &PM, PassBuilder::OptimizationLevel Level) {
|
|
|
|
ExitOnError Err("Unable to parse CGSCCOptimizerLateEP pipeline: ");
|
|
|
|
Err(PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline,
|
|
|
|
VerifyEachPass, DebugLogging));
|
|
|
|
});
|
2017-07-11 13:17:44 +02:00
|
|
|
if (tryParsePipelineText<FunctionPassManager>(PB, VectorizerStartEPPipeline))
|
2018-10-17 12:36:23 +02:00
|
|
|
PB.registerVectorizerStartEPCallback(
|
|
|
|
[&PB, VerifyEachPass, DebugLogging](
|
|
|
|
FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
|
|
|
|
ExitOnError Err("Unable to parse VectorizerStartEP pipeline: ");
|
|
|
|
Err(PB.parsePassPipeline(PM, VectorizerStartEPPipeline,
|
|
|
|
VerifyEachPass, DebugLogging));
|
|
|
|
});
|
2018-01-23 02:25:20 +01:00
|
|
|
if (tryParsePipelineText<ModulePassManager>(PB, PipelineStartEPPipeline))
|
|
|
|
PB.registerPipelineStartEPCallback(
|
|
|
|
[&PB, VerifyEachPass, DebugLogging](ModulePassManager &PM) {
|
2018-10-17 12:36:23 +02:00
|
|
|
ExitOnError Err("Unable to parse PipelineStartEP pipeline: ");
|
|
|
|
Err(PB.parsePassPipeline(PM, PipelineStartEPPipeline, VerifyEachPass,
|
|
|
|
DebugLogging));
|
2018-01-23 02:25:20 +01:00
|
|
|
});
|
2018-11-12 12:17:07 +01:00
|
|
|
if (tryParsePipelineText<FunctionPassManager>(PB, OptimizerLastEPPipeline))
|
|
|
|
PB.registerOptimizerLastEPCallback(
|
|
|
|
[&PB, VerifyEachPass, DebugLogging](FunctionPassManager &PM,
|
|
|
|
PassBuilder::OptimizationLevel) {
|
2018-11-12 13:27:58 +01:00
|
|
|
ExitOnError Err("Unable to parse OptimizerLastEP pipeline: ");
|
|
|
|
Err(PB.parsePassPipeline(PM, OptimizerLastEPPipeline, VerifyEachPass,
|
|
|
|
DebugLogging));
|
2018-11-12 12:17:07 +01:00
|
|
|
});
|
[PM] Enable registration of out-of-tree passes with PassBuilder
Summary:
This patch adds a callback registration API to the PassBuilder,
enabling registering out-of-tree passes with it.
Through the Callback API, callers may register callbacks with the
various stages at which passes are added into pass managers, including
parsing of a pass pipeline as well as at extension points within the
default -O pipelines.
Registering utilities like `require<>` and `invalidate<>` needs to be
handled manually by the caller, but a helper is provided.
Additionally, adding passes at pipeline extension points is exposed
through the opt tool. This patch adds a `-passes-ep-X` commandline
option for every extension point X, which opt parses into pipelines
inserted into that extension point.
Reviewers: chandlerc
Reviewed By: chandlerc
Subscribers: lksbhm, grosser, davide, mehdi_amini, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D33464
llvm-svn: 307532
2017-07-10 12:57:55 +02:00
|
|
|
}
|
|
|
|
|
2017-08-04 11:28:09 +02:00
|
|
|
#ifdef LINK_POLLY_INTO_TOOLS
|
|
|
|
namespace polly {
|
|
|
|
void RegisterPollyPasses(PassBuilder &);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-06-01 03:02:12 +02:00
|
|
|
bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
|
2017-09-23 03:03:17 +02:00
|
|
|
ToolOutputFile *Out, ToolOutputFile *ThinLTOLinkOut,
|
|
|
|
ToolOutputFile *OptRemarkFile,
|
2015-02-01 11:11:22 +01:00
|
|
|
StringRef PassPipeline, OutputKind OK,
|
2015-04-15 02:34:24 +02:00
|
|
|
VerifierKind VK,
|
2015-04-15 04:38:06 +02:00
|
|
|
bool ShouldPreserveAssemblyUseListOrder,
|
2016-08-12 15:53:02 +02:00
|
|
|
bool ShouldPreserveBitcodeUseListOrder,
|
2018-02-15 22:14:36 +01:00
|
|
|
bool EmitSummaryIndex, bool EmitModuleHash,
|
|
|
|
bool EnableDebugify) {
|
[PM] Enable registration of out-of-tree passes with PassBuilder
Summary:
This patch adds a callback registration API to the PassBuilder,
enabling registering out-of-tree passes with it.
Through the Callback API, callers may register callbacks with the
various stages at which passes are added into pass managers, including
parsing of a pass pipeline as well as at extension points within the
default -O pipelines.
Registering utilities like `require<>` and `invalidate<>` needs to be
handled manually by the caller, but a helper is provided.
Additionally, adding passes at pipeline extension points is exposed
through the opt tool. This patch adds a `-passes-ep-X` commandline
option for every extension point X, which opt parses into pipelines
inserted into that extension point.
Reviewers: chandlerc
Reviewed By: chandlerc
Subscribers: lksbhm, grosser, davide, mehdi_amini, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D33464
llvm-svn: 307532
2017-07-10 12:57:55 +02:00
|
|
|
bool VerifyEachPass = VK == VK_VerifyEachPass;
|
2017-07-26 04:00:43 +02:00
|
|
|
|
|
|
|
Optional<PGOOptions> P;
|
|
|
|
switch (PGOKindFlag) {
|
|
|
|
case InstrGen:
|
Add a flag to remap manglings when reading profile data information.
This can be used to preserve profiling information across codebase
changes that have widespread impact on mangled names, but across which
most profiling data should still be usable. For example, when switching
from libstdc++ to libc++, or from the old libstdc++ ABI to the new ABI,
or even from a 32-bit to a 64-bit build.
The user can provide a remapping file specifying parts of mangled names
that should be treated as equivalent (eg, std::__1 should be treated as
equivalent to std::__cxx11), and profile data will be treated as
applying to a particular function if its name is equivalent to the name
of a function in the profile data under the provided equivalences. See
the documentation change for a description of how this is configured.
Remapping is supported for both sample-based profiling and instruction
profiling. We do not support remapping indirect branch target
information, but all other profile data should be remapped
appropriately.
Support is only added for the new pass manager. If someone wants to also
add support for this for the old pass manager, doing so should be
straightforward.
This is the LLVM side of Clang r344199.
Reviewers: davidxl, tejohnson, dlj, erik.pilkington
Subscribers: mehdi_amini, steven_wu, dexonsmith, llvm-commits
Differential Revision: https://reviews.llvm.org/D51249
llvm-svn: 344200
2018-10-11 01:13:47 +02:00
|
|
|
P = PGOOptions(ProfileFile, "", "", "", true);
|
2017-07-26 04:00:43 +02:00
|
|
|
break;
|
|
|
|
case InstrUse:
|
Add a flag to remap manglings when reading profile data information.
This can be used to preserve profiling information across codebase
changes that have widespread impact on mangled names, but across which
most profiling data should still be usable. For example, when switching
from libstdc++ to libc++, or from the old libstdc++ ABI to the new ABI,
or even from a 32-bit to a 64-bit build.
The user can provide a remapping file specifying parts of mangled names
that should be treated as equivalent (eg, std::__1 should be treated as
equivalent to std::__cxx11), and profile data will be treated as
applying to a particular function if its name is equivalent to the name
of a function in the profile data under the provided equivalences. See
the documentation change for a description of how this is configured.
Remapping is supported for both sample-based profiling and instruction
profiling. We do not support remapping indirect branch target
information, but all other profile data should be remapped
appropriately.
Support is only added for the new pass manager. If someone wants to also
add support for this for the old pass manager, doing so should be
straightforward.
This is the LLVM side of Clang r344199.
Reviewers: davidxl, tejohnson, dlj, erik.pilkington
Subscribers: mehdi_amini, steven_wu, dexonsmith, llvm-commits
Differential Revision: https://reviews.llvm.org/D51249
llvm-svn: 344200
2018-10-11 01:13:47 +02:00
|
|
|
P = PGOOptions("", ProfileFile, "", ProfileRemappingFile, false);
|
2017-07-26 04:00:43 +02:00
|
|
|
break;
|
|
|
|
case SampleUse:
|
Add a flag to remap manglings when reading profile data information.
This can be used to preserve profiling information across codebase
changes that have widespread impact on mangled names, but across which
most profiling data should still be usable. For example, when switching
from libstdc++ to libc++, or from the old libstdc++ ABI to the new ABI,
or even from a 32-bit to a 64-bit build.
The user can provide a remapping file specifying parts of mangled names
that should be treated as equivalent (eg, std::__1 should be treated as
equivalent to std::__cxx11), and profile data will be treated as
applying to a particular function if its name is equivalent to the name
of a function in the profile data under the provided equivalences. See
the documentation change for a description of how this is configured.
Remapping is supported for both sample-based profiling and instruction
profiling. We do not support remapping indirect branch target
information, but all other profile data should be remapped
appropriately.
Support is only added for the new pass manager. If someone wants to also
add support for this for the old pass manager, doing so should be
straightforward.
This is the LLVM side of Clang r344199.
Reviewers: davidxl, tejohnson, dlj, erik.pilkington
Subscribers: mehdi_amini, steven_wu, dexonsmith, llvm-commits
Differential Revision: https://reviews.llvm.org/D51249
llvm-svn: 344200
2018-10-11 01:13:47 +02:00
|
|
|
P = PGOOptions("", "", ProfileFile, ProfileRemappingFile, false);
|
2017-07-26 04:00:43 +02:00
|
|
|
break;
|
|
|
|
case NoPGO:
|
2017-07-26 17:01:20 +02:00
|
|
|
if (DebugInfoForProfiling)
|
Add a flag to remap manglings when reading profile data information.
This can be used to preserve profiling information across codebase
changes that have widespread impact on mangled names, but across which
most profiling data should still be usable. For example, when switching
from libstdc++ to libc++, or from the old libstdc++ ABI to the new ABI,
or even from a 32-bit to a 64-bit build.
The user can provide a remapping file specifying parts of mangled names
that should be treated as equivalent (eg, std::__1 should be treated as
equivalent to std::__cxx11), and profile data will be treated as
applying to a particular function if its name is equivalent to the name
of a function in the profile data under the provided equivalences. See
the documentation change for a description of how this is configured.
Remapping is supported for both sample-based profiling and instruction
profiling. We do not support remapping indirect branch target
information, but all other profile data should be remapped
appropriately.
Support is only added for the new pass manager. If someone wants to also
add support for this for the old pass manager, doing so should be
straightforward.
This is the LLVM side of Clang r344199.
Reviewers: davidxl, tejohnson, dlj, erik.pilkington
Subscribers: mehdi_amini, steven_wu, dexonsmith, llvm-commits
Differential Revision: https://reviews.llvm.org/D51249
llvm-svn: 344200
2018-10-11 01:13:47 +02:00
|
|
|
P = PGOOptions("", "", "", "", false, true);
|
2017-07-26 17:01:20 +02:00
|
|
|
else
|
|
|
|
P = None;
|
2017-07-26 04:00:43 +02:00
|
|
|
}
|
2018-09-24 18:08:15 +02:00
|
|
|
PassInstrumentationCallbacks PIC;
|
|
|
|
StandardInstrumentations SI;
|
|
|
|
SI.registerCallbacks(PIC);
|
|
|
|
|
|
|
|
PassBuilder PB(TM, P, &PIC);
|
[PM] Enable registration of out-of-tree passes with PassBuilder
Summary:
This patch adds a callback registration API to the PassBuilder,
enabling registering out-of-tree passes with it.
Through the Callback API, callers may register callbacks with the
various stages at which passes are added into pass managers, including
parsing of a pass pipeline as well as at extension points within the
default -O pipelines.
Registering utilities like `require<>` and `invalidate<>` needs to be
handled manually by the caller, but a helper is provided.
Additionally, adding passes at pipeline extension points is exposed
through the opt tool. This patch adds a `-passes-ep-X` commandline
option for every extension point X, which opt parses into pipelines
inserted into that extension point.
Reviewers: chandlerc
Reviewed By: chandlerc
Subscribers: lksbhm, grosser, davide, mehdi_amini, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D33464
llvm-svn: 307532
2017-07-10 12:57:55 +02:00
|
|
|
registerEPCallbacks(PB, VerifyEachPass, DebugPM);
|
2015-02-01 08:40:05 +01:00
|
|
|
|
2018-04-05 17:04:13 +02:00
|
|
|
// Load requested pass plugins and let them register pass builder callbacks
|
|
|
|
for (auto &PluginFN : PassPlugins) {
|
|
|
|
auto PassPlugin = PassPlugin::Load(PluginFN);
|
|
|
|
if (!PassPlugin) {
|
|
|
|
errs() << "Failed to load passes from '" << PluginFN
|
|
|
|
<< "'. Request ignored.\n";
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
PassPlugin->registerPassBuilderCallbacks(PB);
|
|
|
|
}
|
|
|
|
|
2018-02-15 22:14:36 +01:00
|
|
|
// Register a callback that creates the debugify passes as needed.
|
|
|
|
PB.registerPipelineParsingCallback(
|
|
|
|
[](StringRef Name, ModulePassManager &MPM,
|
|
|
|
ArrayRef<PassBuilder::PipelineElement>) {
|
|
|
|
if (Name == "debugify") {
|
|
|
|
MPM.addPass(NewPMDebugifyPass());
|
|
|
|
return true;
|
|
|
|
} else if (Name == "check-debugify") {
|
|
|
|
MPM.addPass(NewPMCheckDebugifyPass());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2017-08-04 11:28:09 +02:00
|
|
|
#ifdef LINK_POLLY_INTO_TOOLS
|
|
|
|
polly::RegisterPollyPasses(PB);
|
|
|
|
#endif
|
|
|
|
|
2016-02-18 10:45:17 +01:00
|
|
|
// Specially handle the alias analysis manager so that we can register
|
|
|
|
// a custom pipeline of AA passes with it.
|
|
|
|
AAManager AA;
|
2018-10-17 12:36:23 +02:00
|
|
|
if (auto Err = PB.parseAAPipeline(AA, AAPipeline)) {
|
|
|
|
errs() << Arg0 << ": " << toString(std::move(Err)) << "\n";
|
2016-02-18 10:45:17 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-02-25 08:23:08 +01:00
|
|
|
LoopAnalysisManager LAM(DebugPM);
|
2015-01-13 23:42:38 +01:00
|
|
|
FunctionAnalysisManager FAM(DebugPM);
|
|
|
|
CGSCCAnalysisManager CGAM(DebugPM);
|
|
|
|
ModuleAnalysisManager MAM(DebugPM);
|
2014-02-06 05:25:13 +01:00
|
|
|
|
2016-02-18 10:45:17 +01:00
|
|
|
// Register the AA manager first so that our version is the one used.
|
|
|
|
FAM.registerPass([&] { return std::move(AA); });
|
|
|
|
|
2015-01-06 03:21:37 +01:00
|
|
|
// Register all the basic analyses with the managers.
|
2015-03-07 10:02:36 +01:00
|
|
|
PB.registerModuleAnalyses(MAM);
|
|
|
|
PB.registerCGSCCAnalyses(CGAM);
|
|
|
|
PB.registerFunctionAnalyses(FAM);
|
2016-02-25 08:23:08 +01:00
|
|
|
PB.registerLoopAnalyses(LAM);
|
2016-05-15 01:21:50 +02:00
|
|
|
PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
|
2014-02-06 05:25:13 +01:00
|
|
|
|
2015-01-13 23:42:38 +01:00
|
|
|
ModulePassManager MPM(DebugPM);
|
2014-01-20 12:34:08 +01:00
|
|
|
if (VK > VK_NoVerifier)
|
|
|
|
MPM.addPass(VerifierPass());
|
2018-02-15 22:14:36 +01:00
|
|
|
if (EnableDebugify)
|
|
|
|
MPM.addPass(NewPMDebugifyPass());
|
2014-01-20 12:34:08 +01:00
|
|
|
|
2018-10-17 12:36:23 +02:00
|
|
|
if (auto Err =
|
|
|
|
PB.parsePassPipeline(MPM, PassPipeline, VerifyEachPass, DebugPM)) {
|
|
|
|
errs() << Arg0 << ": " << toString(std::move(Err)) << "\n";
|
[PM] Add (very skeletal) support to opt for running the new pass
manager. I cannot emphasize enough that this is a WIP. =] I expect it
to change a great deal as things stabilize, but I think its really
important to get *some* functionality here so that the infrastructure
can be tested more traditionally from the commandline.
The current design is looking something like this:
./bin/opt -passes='module(pass_a,pass_b,function(pass_c,pass_d))'
So rather than custom-parsed flags, there is a single flag with a string
argument that is parsed into the pass pipeline structure. This makes it
really easy to have nice structural properties that are very explicit.
There is one obvious and important shortcut. You can start off the
pipeline with a pass, and the minimal context of pass managers will be
built around the entire specified pipeline. This makes the common case
for tests super easy:
./bin/opt -passes=instcombine,sroa,gvn
But this won't introduce any of the complexity of the fully inferred old
system -- we only ever do this for the *entire* argument, and we only
look at the first pass. If the other passes don't fit in the pass
manager selected it is a hard error.
The other interesting aspect here is that I'm not relying on any
registration facilities. Such facilities may be unavoidable for
supporting plugins, but I have alternative ideas for plugins that I'd
like to try first. My plan is essentially to build everything without
registration until we hit an absolute requirement.
Instead of registration of pass names, there will be a library dedicated
to parsing pass names and the pass pipeline strings described above.
Currently, this is directly embedded into opt for simplicity as it is
very early, but I plan to eventually pull this into a library that opt,
bugpoint, and even Clang can depend on. It should end up as a good home
for things like the existing PassManagerBuilder as well.
There are a bunch of FIXMEs in the code for the parts of this that are
just stubbed out to make the patch more incremental. A quick list of
what's coming up directly after this:
- Support for function passes and building the structured nesting.
- Support for printing the pass structure, and FileCheck tests of all of
this code.
- The .def-file based pass name parsing.
- IR priting passes and the corresponding tests.
Some obvious things that I'm not going to do right now, but am
definitely planning on as the pass manager work gets a bit further:
- Pull the parsing into library, including the builders.
- Thread the rest of the target stuff into the new pass manager.
- Wire support for the new pass manager up to llc.
- Plugin support.
Some things that I'd like to have, but are significantly lower on my
priority list. I'll get to these eventually, but they may also be places
where others want to contribute:
- Adding nice error reporting for broken pass pipeline descriptions.
- Typo-correction for pass names.
llvm-svn: 198998
2014-01-11 09:16:35 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-01-20 12:34:08 +01:00
|
|
|
if (VK > VK_NoVerifier)
|
|
|
|
MPM.addPass(VerifierPass());
|
2018-02-15 22:14:36 +01:00
|
|
|
if (EnableDebugify)
|
|
|
|
MPM.addPass(NewPMCheckDebugifyPass());
|
2014-01-20 12:34:08 +01:00
|
|
|
|
2014-01-13 06:16:45 +01:00
|
|
|
// Add any relevant output pass at the end of the pipeline.
|
|
|
|
switch (OK) {
|
|
|
|
case OK_NoOutput:
|
|
|
|
break; // No output pass needed.
|
|
|
|
case OK_OutputAssembly:
|
2015-04-15 04:38:06 +02:00
|
|
|
MPM.addPass(
|
|
|
|
PrintModulePass(Out->os(), "", ShouldPreserveAssemblyUseListOrder));
|
2014-01-13 06:16:45 +01:00
|
|
|
break;
|
|
|
|
case OK_OutputBitcode:
|
2016-08-12 15:53:02 +02:00
|
|
|
MPM.addPass(BitcodeWriterPass(Out->os(), ShouldPreserveBitcodeUseListOrder,
|
|
|
|
EmitSummaryIndex, EmitModuleHash));
|
2014-01-13 08:38:24 +01:00
|
|
|
break;
|
2017-06-01 03:02:12 +02:00
|
|
|
case OK_OutputThinLTOBitcode:
|
|
|
|
MPM.addPass(ThinLTOBitcodeWriterPass(
|
|
|
|
Out->os(), ThinLTOLinkOut ? &ThinLTOLinkOut->os() : nullptr));
|
|
|
|
break;
|
2014-01-13 06:16:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Before executing passes, print the final values of the LLVM options.
|
|
|
|
cl::PrintOptionValues();
|
|
|
|
|
[PM] Add (very skeletal) support to opt for running the new pass
manager. I cannot emphasize enough that this is a WIP. =] I expect it
to change a great deal as things stabilize, but I think its really
important to get *some* functionality here so that the infrastructure
can be tested more traditionally from the commandline.
The current design is looking something like this:
./bin/opt -passes='module(pass_a,pass_b,function(pass_c,pass_d))'
So rather than custom-parsed flags, there is a single flag with a string
argument that is parsed into the pass pipeline structure. This makes it
really easy to have nice structural properties that are very explicit.
There is one obvious and important shortcut. You can start off the
pipeline with a pass, and the minimal context of pass managers will be
built around the entire specified pipeline. This makes the common case
for tests super easy:
./bin/opt -passes=instcombine,sroa,gvn
But this won't introduce any of the complexity of the fully inferred old
system -- we only ever do this for the *entire* argument, and we only
look at the first pass. If the other passes don't fit in the pass
manager selected it is a hard error.
The other interesting aspect here is that I'm not relying on any
registration facilities. Such facilities may be unavoidable for
supporting plugins, but I have alternative ideas for plugins that I'd
like to try first. My plan is essentially to build everything without
registration until we hit an absolute requirement.
Instead of registration of pass names, there will be a library dedicated
to parsing pass names and the pass pipeline strings described above.
Currently, this is directly embedded into opt for simplicity as it is
very early, but I plan to eventually pull this into a library that opt,
bugpoint, and even Clang can depend on. It should end up as a good home
for things like the existing PassManagerBuilder as well.
There are a bunch of FIXMEs in the code for the parts of this that are
just stubbed out to make the patch more incremental. A quick list of
what's coming up directly after this:
- Support for function passes and building the structured nesting.
- Support for printing the pass structure, and FileCheck tests of all of
this code.
- The .def-file based pass name parsing.
- IR priting passes and the corresponding tests.
Some obvious things that I'm not going to do right now, but am
definitely planning on as the pass manager work gets a bit further:
- Pull the parsing into library, including the builders.
- Thread the rest of the target stuff into the new pass manager.
- Wire support for the new pass manager up to llc.
- Plugin support.
Some things that I'd like to have, but are significantly lower on my
priority list. I'll get to these eventually, but they may also be places
where others want to contribute:
- Adding nice error reporting for broken pass pipeline descriptions.
- Typo-correction for pass names.
llvm-svn: 198998
2014-01-11 09:16:35 +01:00
|
|
|
// Now that we have all of the passes ready, run them.
|
2016-03-11 12:05:24 +01:00
|
|
|
MPM.run(M, MAM);
|
[PM] Add (very skeletal) support to opt for running the new pass
manager. I cannot emphasize enough that this is a WIP. =] I expect it
to change a great deal as things stabilize, but I think its really
important to get *some* functionality here so that the infrastructure
can be tested more traditionally from the commandline.
The current design is looking something like this:
./bin/opt -passes='module(pass_a,pass_b,function(pass_c,pass_d))'
So rather than custom-parsed flags, there is a single flag with a string
argument that is parsed into the pass pipeline structure. This makes it
really easy to have nice structural properties that are very explicit.
There is one obvious and important shortcut. You can start off the
pipeline with a pass, and the minimal context of pass managers will be
built around the entire specified pipeline. This makes the common case
for tests super easy:
./bin/opt -passes=instcombine,sroa,gvn
But this won't introduce any of the complexity of the fully inferred old
system -- we only ever do this for the *entire* argument, and we only
look at the first pass. If the other passes don't fit in the pass
manager selected it is a hard error.
The other interesting aspect here is that I'm not relying on any
registration facilities. Such facilities may be unavoidable for
supporting plugins, but I have alternative ideas for plugins that I'd
like to try first. My plan is essentially to build everything without
registration until we hit an absolute requirement.
Instead of registration of pass names, there will be a library dedicated
to parsing pass names and the pass pipeline strings described above.
Currently, this is directly embedded into opt for simplicity as it is
very early, but I plan to eventually pull this into a library that opt,
bugpoint, and even Clang can depend on. It should end up as a good home
for things like the existing PassManagerBuilder as well.
There are a bunch of FIXMEs in the code for the parts of this that are
just stubbed out to make the patch more incremental. A quick list of
what's coming up directly after this:
- Support for function passes and building the structured nesting.
- Support for printing the pass structure, and FileCheck tests of all of
this code.
- The .def-file based pass name parsing.
- IR priting passes and the corresponding tests.
Some obvious things that I'm not going to do right now, but am
definitely planning on as the pass manager work gets a bit further:
- Pull the parsing into library, including the builders.
- Thread the rest of the target stuff into the new pass manager.
- Wire support for the new pass manager up to llc.
- Plugin support.
Some things that I'd like to have, but are significantly lower on my
priority list. I'll get to these eventually, but they may also be places
where others want to contribute:
- Adding nice error reporting for broken pass pipeline descriptions.
- Typo-correction for pass names.
llvm-svn: 198998
2014-01-11 09:16:35 +01:00
|
|
|
|
|
|
|
// Declare success.
|
2017-06-01 03:02:12 +02:00
|
|
|
if (OK != OK_NoOutput) {
|
[PM] Add (very skeletal) support to opt for running the new pass
manager. I cannot emphasize enough that this is a WIP. =] I expect it
to change a great deal as things stabilize, but I think its really
important to get *some* functionality here so that the infrastructure
can be tested more traditionally from the commandline.
The current design is looking something like this:
./bin/opt -passes='module(pass_a,pass_b,function(pass_c,pass_d))'
So rather than custom-parsed flags, there is a single flag with a string
argument that is parsed into the pass pipeline structure. This makes it
really easy to have nice structural properties that are very explicit.
There is one obvious and important shortcut. You can start off the
pipeline with a pass, and the minimal context of pass managers will be
built around the entire specified pipeline. This makes the common case
for tests super easy:
./bin/opt -passes=instcombine,sroa,gvn
But this won't introduce any of the complexity of the fully inferred old
system -- we only ever do this for the *entire* argument, and we only
look at the first pass. If the other passes don't fit in the pass
manager selected it is a hard error.
The other interesting aspect here is that I'm not relying on any
registration facilities. Such facilities may be unavoidable for
supporting plugins, but I have alternative ideas for plugins that I'd
like to try first. My plan is essentially to build everything without
registration until we hit an absolute requirement.
Instead of registration of pass names, there will be a library dedicated
to parsing pass names and the pass pipeline strings described above.
Currently, this is directly embedded into opt for simplicity as it is
very early, but I plan to eventually pull this into a library that opt,
bugpoint, and even Clang can depend on. It should end up as a good home
for things like the existing PassManagerBuilder as well.
There are a bunch of FIXMEs in the code for the parts of this that are
just stubbed out to make the patch more incremental. A quick list of
what's coming up directly after this:
- Support for function passes and building the structured nesting.
- Support for printing the pass structure, and FileCheck tests of all of
this code.
- The .def-file based pass name parsing.
- IR priting passes and the corresponding tests.
Some obvious things that I'm not going to do right now, but am
definitely planning on as the pass manager work gets a bit further:
- Pull the parsing into library, including the builders.
- Thread the rest of the target stuff into the new pass manager.
- Wire support for the new pass manager up to llc.
- Plugin support.
Some things that I'd like to have, but are significantly lower on my
priority list. I'll get to these eventually, but they may also be places
where others want to contribute:
- Adding nice error reporting for broken pass pipeline descriptions.
- Typo-correction for pass names.
llvm-svn: 198998
2014-01-11 09:16:35 +01:00
|
|
|
Out->keep();
|
2017-06-01 03:02:12 +02:00
|
|
|
if (OK == OK_OutputThinLTOBitcode && ThinLTOLinkOut)
|
|
|
|
ThinLTOLinkOut->keep();
|
|
|
|
}
|
2017-08-20 03:30:45 +02:00
|
|
|
|
|
|
|
if (OptRemarkFile)
|
|
|
|
OptRemarkFile->keep();
|
|
|
|
|
[PM] Add (very skeletal) support to opt for running the new pass
manager. I cannot emphasize enough that this is a WIP. =] I expect it
to change a great deal as things stabilize, but I think its really
important to get *some* functionality here so that the infrastructure
can be tested more traditionally from the commandline.
The current design is looking something like this:
./bin/opt -passes='module(pass_a,pass_b,function(pass_c,pass_d))'
So rather than custom-parsed flags, there is a single flag with a string
argument that is parsed into the pass pipeline structure. This makes it
really easy to have nice structural properties that are very explicit.
There is one obvious and important shortcut. You can start off the
pipeline with a pass, and the minimal context of pass managers will be
built around the entire specified pipeline. This makes the common case
for tests super easy:
./bin/opt -passes=instcombine,sroa,gvn
But this won't introduce any of the complexity of the fully inferred old
system -- we only ever do this for the *entire* argument, and we only
look at the first pass. If the other passes don't fit in the pass
manager selected it is a hard error.
The other interesting aspect here is that I'm not relying on any
registration facilities. Such facilities may be unavoidable for
supporting plugins, but I have alternative ideas for plugins that I'd
like to try first. My plan is essentially to build everything without
registration until we hit an absolute requirement.
Instead of registration of pass names, there will be a library dedicated
to parsing pass names and the pass pipeline strings described above.
Currently, this is directly embedded into opt for simplicity as it is
very early, but I plan to eventually pull this into a library that opt,
bugpoint, and even Clang can depend on. It should end up as a good home
for things like the existing PassManagerBuilder as well.
There are a bunch of FIXMEs in the code for the parts of this that are
just stubbed out to make the patch more incremental. A quick list of
what's coming up directly after this:
- Support for function passes and building the structured nesting.
- Support for printing the pass structure, and FileCheck tests of all of
this code.
- The .def-file based pass name parsing.
- IR priting passes and the corresponding tests.
Some obvious things that I'm not going to do right now, but am
definitely planning on as the pass manager work gets a bit further:
- Pull the parsing into library, including the builders.
- Thread the rest of the target stuff into the new pass manager.
- Wire support for the new pass manager up to llc.
- Plugin support.
Some things that I'd like to have, but are significantly lower on my
priority list. I'll get to these eventually, but they may also be places
where others want to contribute:
- Adding nice error reporting for broken pass pipeline descriptions.
- Typo-correction for pass names.
llvm-svn: 198998
2014-01-11 09:16:35 +01:00
|
|
|
return true;
|
|
|
|
}
|