[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"
|
|
|
|
#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"
|
2017-08-04 11:28:09 +02:00
|
|
|
#include "llvm/Config/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"
|
[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"));
|
|
|
|
|
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);
|
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);
|
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>
|
|
|
|
bool tryParsePipelineText(PassBuilder &PB, StringRef PipelineText) {
|
|
|
|
if (PipelineText.empty())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Verify the pipeline is parseable:
|
|
|
|
PassManagerT PM;
|
|
|
|
if (PB.parsePassPipeline(PM, PipelineText))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
errs() << "Could not parse pipeline '" << PipelineText
|
|
|
|
<< "'. I'm going to igore it.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
[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))
|
2017-07-10 14:48:51 +02:00
|
|
|
PB.registerPeepholeEPCallback([&PB, VerifyEachPass, DebugLogging](
|
|
|
|
FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
|
2017-07-11 13:17:44 +02:00
|
|
|
PB.parsePassPipeline(PM, PeepholeEPPipeline, VerifyEachPass,
|
|
|
|
DebugLogging);
|
2017-07-10 14:48:51 +02:00
|
|
|
});
|
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) {
|
2017-07-11 13:17:44 +02:00
|
|
|
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))
|
2017-07-10 14:48:51 +02:00
|
|
|
PB.registerLoopOptimizerEndEPCallback([&PB, VerifyEachPass, DebugLogging](
|
|
|
|
LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
|
2017-07-11 13:17:44 +02:00
|
|
|
PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline, VerifyEachPass,
|
|
|
|
DebugLogging);
|
2017-07-10 14:48:51 +02:00
|
|
|
});
|
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) {
|
2017-07-11 13:17:44 +02:00
|
|
|
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))
|
2017-07-10 14:48:51 +02:00
|
|
|
PB.registerCGSCCOptimizerLateEPCallback([&PB, VerifyEachPass, DebugLogging](
|
|
|
|
CGSCCPassManager &PM, PassBuilder::OptimizationLevel Level) {
|
2017-07-11 13:17:44 +02:00
|
|
|
PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline, VerifyEachPass,
|
|
|
|
DebugLogging);
|
2017-07-10 14:48:51 +02:00
|
|
|
});
|
2017-07-11 13:17:44 +02:00
|
|
|
if (tryParsePipelineText<FunctionPassManager>(PB, VectorizerStartEPPipeline))
|
2017-07-10 14:48:51 +02:00
|
|
|
PB.registerVectorizerStartEPCallback([&PB, VerifyEachPass, DebugLogging](
|
|
|
|
FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
|
2017-07-11 13:17:44 +02:00
|
|
|
PB.parsePassPipeline(PM, VectorizerStartEPPipeline, VerifyEachPass,
|
|
|
|
DebugLogging);
|
2017-07-10 14:48:51 +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
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
tool_output_file *Out,
|
|
|
|
tool_output_file *ThinLTOLinkOut,
|
2017-08-20 03:30:45 +02:00
|
|
|
tool_output_file *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,
|
|
|
|
bool EmitSummaryIndex, bool EmitModuleHash) {
|
[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:
|
|
|
|
P = PGOOptions(ProfileFile, "", "", true);
|
|
|
|
break;
|
|
|
|
case InstrUse:
|
|
|
|
P = PGOOptions("", ProfileFile, "", false);
|
|
|
|
break;
|
|
|
|
case SampleUse:
|
|
|
|
P = PGOOptions("", "", ProfileFile, false);
|
|
|
|
break;
|
|
|
|
case NoPGO:
|
2017-07-26 17:01:20 +02:00
|
|
|
if (DebugInfoForProfiling)
|
|
|
|
P = PGOOptions("", "", "", false, true);
|
|
|
|
else
|
|
|
|
P = None;
|
2017-07-26 04:00:43 +02:00
|
|
|
}
|
|
|
|
PassBuilder PB(TM, P);
|
[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
|
|
|
|
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;
|
|
|
|
if (!PB.parseAAPipeline(AA, AAPipeline)) {
|
|
|
|
errs() << Arg0 << ": unable to parse AA pipeline description.\n";
|
|
|
|
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());
|
|
|
|
|
[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 (!PB.parsePassPipeline(MPM, PassPipeline, VerifyEachPass, DebugPM)) {
|
[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
|
|
|
errs() << Arg0 << ": unable to parse pass pipeline description.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-01-20 12:34:08 +01:00
|
|
|
if (VK > VK_NoVerifier)
|
|
|
|
MPM.addPass(VerifierPass());
|
|
|
|
|
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;
|
|
|
|
}
|