[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
//===- Passes.cpp - Parsing, selection, and running of passes -------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// \file
|
|
|
|
///
|
|
|
|
/// This file provides the infrastructure to parse and build a custom pass
|
|
|
|
/// manager based on a commandline flag. It also provides helpers to aid in
|
|
|
|
/// analyzing, debugging, and testing pass structures.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "Passes.h"
|
2015-01-22 21:53:09 +00:00
|
|
|
#include "llvm/Analysis/AssumptionCache.h"
|
2014-04-21 11:12:00 +00:00
|
|
|
#include "llvm/Analysis/CGSCCPassManager.h"
|
2014-02-06 04:37:03 +00:00
|
|
|
#include "llvm/Analysis/LazyCallGraph.h"
|
2015-01-20 10:58:50 +00:00
|
|
|
#include "llvm/Analysis/LoopInfo.h"
|
2015-01-15 11:39:46 +00:00
|
|
|
#include "llvm/Analysis/TargetLibraryInfo.h"
|
2015-02-01 10:11:22 +00:00
|
|
|
#include "llvm/Analysis/TargetTransformInfo.h"
|
2015-01-14 10:19:28 +00:00
|
|
|
#include "llvm/IR/Dominators.h"
|
2014-01-12 12:15:39 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
#include "llvm/IR/PassManager.h"
|
2014-01-20 11:34:08 +00:00
|
|
|
#include "llvm/IR/Verifier.h"
|
2014-01-12 12:15:39 +00:00
|
|
|
#include "llvm/Support/Debug.h"
|
2015-02-01 10:11:22 +00:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2015-01-24 04:19:17 +00:00
|
|
|
#include "llvm/Transforms/InstCombine/InstCombine.h"
|
2015-02-01 10:51:23 +00:00
|
|
|
#include "llvm/Transforms/Scalar/EarlyCSE.h"
|
2015-01-24 11:13:02 +00:00
|
|
|
#include "llvm/Transforms/Scalar/LowerExpectIntrinsic.h"
|
2015-02-01 11:34:21 +00:00
|
|
|
#include "llvm/Transforms/Scalar/SimplifyCFG.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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2014-01-12 09:34:22 +00:00
|
|
|
/// \brief No-op module pass which does nothing.
|
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
struct NoOpModulePass {
|
2015-01-05 02:47:05 +00:00
|
|
|
PreservedAnalyses run(Module &M) { return PreservedAnalyses::all(); }
|
2014-01-11 11:52:05 +00:00
|
|
|
static StringRef name() { return "NoOpModulePass"; }
|
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
};
|
|
|
|
|
2015-01-06 02:50:06 +00:00
|
|
|
/// \brief No-op module analysis.
|
|
|
|
struct NoOpModuleAnalysis {
|
|
|
|
struct Result {};
|
|
|
|
Result run(Module &) { return Result(); }
|
|
|
|
static StringRef name() { return "NoOpModuleAnalysis"; }
|
|
|
|
static void *ID() { return (void *)&PassID; }
|
|
|
|
private:
|
|
|
|
static char PassID;
|
|
|
|
};
|
|
|
|
|
|
|
|
char NoOpModuleAnalysis::PassID;
|
|
|
|
|
2014-04-21 11:12:00 +00:00
|
|
|
/// \brief No-op CGSCC pass which does nothing.
|
|
|
|
struct NoOpCGSCCPass {
|
2015-01-05 02:47:05 +00:00
|
|
|
PreservedAnalyses run(LazyCallGraph::SCC &C) {
|
2014-04-21 11:12:00 +00:00
|
|
|
return PreservedAnalyses::all();
|
|
|
|
}
|
|
|
|
static StringRef name() { return "NoOpCGSCCPass"; }
|
|
|
|
};
|
|
|
|
|
2015-01-06 02:50:06 +00:00
|
|
|
/// \brief No-op CGSCC analysis.
|
|
|
|
struct NoOpCGSCCAnalysis {
|
|
|
|
struct Result {};
|
|
|
|
Result run(LazyCallGraph::SCC &) { return Result(); }
|
|
|
|
static StringRef name() { return "NoOpCGSCCAnalysis"; }
|
|
|
|
static void *ID() { return (void *)&PassID; }
|
|
|
|
private:
|
|
|
|
static char PassID;
|
|
|
|
};
|
|
|
|
|
|
|
|
char NoOpCGSCCAnalysis::PassID;
|
|
|
|
|
2014-01-12 09:34:22 +00:00
|
|
|
/// \brief No-op function pass which does nothing.
|
|
|
|
struct NoOpFunctionPass {
|
2015-01-05 02:47:05 +00:00
|
|
|
PreservedAnalyses run(Function &F) { return PreservedAnalyses::all(); }
|
2014-01-12 09:34:22 +00:00
|
|
|
static StringRef name() { return "NoOpFunctionPass"; }
|
|
|
|
};
|
|
|
|
|
2015-01-06 02:50:06 +00:00
|
|
|
/// \brief No-op function analysis.
|
|
|
|
struct NoOpFunctionAnalysis {
|
|
|
|
struct Result {};
|
|
|
|
Result run(Function &) { return Result(); }
|
|
|
|
static StringRef name() { return "NoOpFunctionAnalysis"; }
|
|
|
|
static void *ID() { return (void *)&PassID; }
|
|
|
|
private:
|
|
|
|
static char PassID;
|
|
|
|
};
|
|
|
|
|
|
|
|
char NoOpFunctionAnalysis::PassID;
|
|
|
|
|
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
} // End anonymous namespace.
|
|
|
|
|
2015-02-01 07:40:05 +00:00
|
|
|
void Passes::registerModuleAnalyses(ModuleAnalysisManager &MAM) {
|
2015-01-06 02:21:37 +00:00
|
|
|
#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
|
|
|
|
MAM.registerPass(CREATE_PASS);
|
|
|
|
#include "PassRegistry.def"
|
|
|
|
}
|
|
|
|
|
2015-02-01 07:40:05 +00:00
|
|
|
void Passes::registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM) {
|
2015-01-06 02:21:37 +00:00
|
|
|
#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
|
|
|
|
CGAM.registerPass(CREATE_PASS);
|
|
|
|
#include "PassRegistry.def"
|
|
|
|
}
|
|
|
|
|
2015-02-01 07:40:05 +00:00
|
|
|
void Passes::registerFunctionAnalyses(FunctionAnalysisManager &FAM) {
|
2015-01-06 02:21:37 +00:00
|
|
|
#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
|
|
|
|
FAM.registerPass(CREATE_PASS);
|
|
|
|
#include "PassRegistry.def"
|
|
|
|
}
|
|
|
|
|
2015-01-06 09:10:47 +00:00
|
|
|
#ifndef NDEBUG
|
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
static bool isModulePassName(StringRef Name) {
|
2014-04-21 08:08:50 +00:00
|
|
|
#define MODULE_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
|
2015-01-06 02:10:51 +00:00
|
|
|
#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
|
2015-01-06 04:49:44 +00:00
|
|
|
if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
|
2015-01-06 02:10:51 +00:00
|
|
|
return true;
|
|
|
|
#include "PassRegistry.def"
|
|
|
|
|
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
2015-01-06 09:10:47 +00:00
|
|
|
#endif
|
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
|
2014-04-21 11:12:00 +00:00
|
|
|
static bool isCGSCCPassName(StringRef Name) {
|
|
|
|
#define CGSCC_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
|
2015-01-06 02:10:51 +00:00
|
|
|
#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
|
2015-01-06 04:49:44 +00:00
|
|
|
if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
|
2015-01-06 02:10:51 +00:00
|
|
|
return true;
|
|
|
|
#include "PassRegistry.def"
|
|
|
|
|
2014-04-21 11:12:00 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-01-12 09:34:22 +00:00
|
|
|
static bool isFunctionPassName(StringRef Name) {
|
2014-04-21 08:08:50 +00:00
|
|
|
#define FUNCTION_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
|
2015-01-06 02:10:51 +00:00
|
|
|
#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
|
2015-01-06 04:49:44 +00:00
|
|
|
if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
|
2015-01-06 02:10:51 +00:00
|
|
|
return true;
|
|
|
|
#include "PassRegistry.def"
|
|
|
|
|
2014-01-12 09:34:22 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-01 07:40:05 +00:00
|
|
|
bool Passes::parseModulePassName(ModulePassManager &MPM, StringRef Name) {
|
2014-04-21 08:08:50 +00:00
|
|
|
#define MODULE_PASS(NAME, CREATE_PASS) \
|
|
|
|
if (Name == NAME) { \
|
|
|
|
MPM.addPass(CREATE_PASS); \
|
|
|
|
return true; \
|
2014-02-06 04:37:03 +00:00
|
|
|
}
|
2015-01-06 02:10:51 +00:00
|
|
|
#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
|
|
|
|
if (Name == "require<" NAME ">") { \
|
2015-01-07 11:14:51 +00:00
|
|
|
MPM.addPass(RequireAnalysisPass<decltype(CREATE_PASS)>()); \
|
2015-01-06 02:10:51 +00:00
|
|
|
return true; \
|
2015-01-06 04:49:44 +00:00
|
|
|
} \
|
|
|
|
if (Name == "invalidate<" NAME ">") { \
|
2015-01-07 11:14:51 +00:00
|
|
|
MPM.addPass(InvalidateAnalysisPass<decltype(CREATE_PASS)>()); \
|
2015-01-06 04:49:44 +00:00
|
|
|
return true; \
|
2015-01-06 02:10:51 +00:00
|
|
|
}
|
|
|
|
#include "PassRegistry.def"
|
|
|
|
|
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-01 07:40:05 +00:00
|
|
|
bool Passes::parseCGSCCPassName(CGSCCPassManager &CGPM, StringRef Name) {
|
2014-04-21 11:12:00 +00:00
|
|
|
#define CGSCC_PASS(NAME, CREATE_PASS) \
|
|
|
|
if (Name == NAME) { \
|
|
|
|
CGPM.addPass(CREATE_PASS); \
|
|
|
|
return true; \
|
|
|
|
}
|
2015-01-06 02:10:51 +00:00
|
|
|
#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
|
|
|
|
if (Name == "require<" NAME ">") { \
|
2015-01-07 11:14:51 +00:00
|
|
|
CGPM.addPass(RequireAnalysisPass<decltype(CREATE_PASS)>()); \
|
2015-01-06 02:10:51 +00:00
|
|
|
return true; \
|
2015-01-06 04:49:44 +00:00
|
|
|
} \
|
|
|
|
if (Name == "invalidate<" NAME ">") { \
|
2015-01-07 11:14:51 +00:00
|
|
|
CGPM.addPass(InvalidateAnalysisPass<decltype(CREATE_PASS)>()); \
|
2015-01-06 04:49:44 +00:00
|
|
|
return true; \
|
2015-01-06 02:10:51 +00:00
|
|
|
}
|
|
|
|
#include "PassRegistry.def"
|
|
|
|
|
2014-04-21 11:12:00 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-01 07:40:05 +00:00
|
|
|
bool Passes::parseFunctionPassName(FunctionPassManager &FPM, StringRef Name) {
|
2014-04-21 08:08:50 +00:00
|
|
|
#define FUNCTION_PASS(NAME, CREATE_PASS) \
|
|
|
|
if (Name == NAME) { \
|
|
|
|
FPM.addPass(CREATE_PASS); \
|
|
|
|
return true; \
|
2014-01-12 12:15:39 +00:00
|
|
|
}
|
2015-01-06 02:10:51 +00:00
|
|
|
#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
|
|
|
|
if (Name == "require<" NAME ">") { \
|
2015-01-07 11:14:51 +00:00
|
|
|
FPM.addPass(RequireAnalysisPass<decltype(CREATE_PASS)>()); \
|
2015-01-06 02:10:51 +00:00
|
|
|
return true; \
|
2015-01-06 04:49:44 +00:00
|
|
|
} \
|
|
|
|
if (Name == "invalidate<" NAME ">") { \
|
2015-01-07 11:14:51 +00:00
|
|
|
FPM.addPass(InvalidateAnalysisPass<decltype(CREATE_PASS)>()); \
|
2015-01-06 04:49:44 +00:00
|
|
|
return true; \
|
2015-01-06 02:10:51 +00:00
|
|
|
}
|
|
|
|
#include "PassRegistry.def"
|
|
|
|
|
2014-01-12 09:34:22 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-01 07:40:05 +00:00
|
|
|
bool Passes::parseFunctionPassPipeline(FunctionPassManager &FPM,
|
|
|
|
StringRef &PipelineText,
|
|
|
|
bool VerifyEachPass, bool DebugLogging) {
|
2014-01-12 09:34:22 +00:00
|
|
|
for (;;) {
|
|
|
|
// Parse nested pass managers by recursing.
|
|
|
|
if (PipelineText.startswith("function(")) {
|
2015-01-13 22:42:38 +00:00
|
|
|
FunctionPassManager NestedFPM(DebugLogging);
|
2014-01-12 09:34:22 +00:00
|
|
|
|
|
|
|
// Parse the inner pipeline inte the nested manager.
|
|
|
|
PipelineText = PipelineText.substr(strlen("function("));
|
2015-01-13 22:42:38 +00:00
|
|
|
if (!parseFunctionPassPipeline(NestedFPM, PipelineText, VerifyEachPass,
|
|
|
|
DebugLogging) ||
|
2014-01-12 10:02:02 +00:00
|
|
|
PipelineText.empty())
|
2014-01-12 09:34:22 +00:00
|
|
|
return false;
|
2014-01-12 10:02:02 +00:00
|
|
|
assert(PipelineText[0] == ')');
|
2014-01-12 09:34:22 +00:00
|
|
|
PipelineText = PipelineText.substr(1);
|
|
|
|
|
|
|
|
// Add the nested pass manager with the appropriate adaptor.
|
2014-03-09 11:49:53 +00:00
|
|
|
FPM.addPass(std::move(NestedFPM));
|
2014-01-12 09:34:22 +00:00
|
|
|
} else {
|
|
|
|
// Otherwise try to parse a pass name.
|
|
|
|
size_t End = PipelineText.find_first_of(",)");
|
|
|
|
if (!parseFunctionPassName(FPM, PipelineText.substr(0, End)))
|
|
|
|
return false;
|
2014-01-20 11:34:08 +00:00
|
|
|
if (VerifyEachPass)
|
|
|
|
FPM.addPass(VerifierPass());
|
2014-01-12 09:34:22 +00:00
|
|
|
|
|
|
|
PipelineText = PipelineText.substr(End);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PipelineText.empty() || PipelineText[0] == ')')
|
|
|
|
return true;
|
|
|
|
|
|
|
|
assert(PipelineText[0] == ',');
|
|
|
|
PipelineText = PipelineText.substr(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-01 07:40:05 +00:00
|
|
|
bool Passes::parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
|
|
|
|
StringRef &PipelineText,
|
|
|
|
bool VerifyEachPass, bool DebugLogging) {
|
2014-04-21 11:12:00 +00:00
|
|
|
for (;;) {
|
|
|
|
// Parse nested pass managers by recursing.
|
|
|
|
if (PipelineText.startswith("cgscc(")) {
|
2015-01-13 22:42:38 +00:00
|
|
|
CGSCCPassManager NestedCGPM(DebugLogging);
|
2014-04-21 11:12:00 +00:00
|
|
|
|
|
|
|
// Parse the inner pipeline into the nested manager.
|
|
|
|
PipelineText = PipelineText.substr(strlen("cgscc("));
|
2015-01-13 22:42:38 +00:00
|
|
|
if (!parseCGSCCPassPipeline(NestedCGPM, PipelineText, VerifyEachPass,
|
|
|
|
DebugLogging) ||
|
2014-04-21 11:12:00 +00:00
|
|
|
PipelineText.empty())
|
|
|
|
return false;
|
|
|
|
assert(PipelineText[0] == ')');
|
|
|
|
PipelineText = PipelineText.substr(1);
|
|
|
|
|
|
|
|
// Add the nested pass manager with the appropriate adaptor.
|
|
|
|
CGPM.addPass(std::move(NestedCGPM));
|
|
|
|
} else if (PipelineText.startswith("function(")) {
|
2015-01-13 22:42:38 +00:00
|
|
|
FunctionPassManager NestedFPM(DebugLogging);
|
2014-04-21 11:12:00 +00:00
|
|
|
|
|
|
|
// Parse the inner pipeline inte the nested manager.
|
|
|
|
PipelineText = PipelineText.substr(strlen("function("));
|
2015-01-13 22:42:38 +00:00
|
|
|
if (!parseFunctionPassPipeline(NestedFPM, PipelineText, VerifyEachPass,
|
|
|
|
DebugLogging) ||
|
2014-04-21 11:12:00 +00:00
|
|
|
PipelineText.empty())
|
|
|
|
return false;
|
|
|
|
assert(PipelineText[0] == ')');
|
|
|
|
PipelineText = PipelineText.substr(1);
|
|
|
|
|
|
|
|
// Add the nested pass manager with the appropriate adaptor.
|
|
|
|
CGPM.addPass(createCGSCCToFunctionPassAdaptor(std::move(NestedFPM)));
|
|
|
|
} else {
|
|
|
|
// Otherwise try to parse a pass name.
|
|
|
|
size_t End = PipelineText.find_first_of(",)");
|
|
|
|
if (!parseCGSCCPassName(CGPM, PipelineText.substr(0, End)))
|
|
|
|
return false;
|
|
|
|
// FIXME: No verifier support for CGSCC passes!
|
|
|
|
|
|
|
|
PipelineText = PipelineText.substr(End);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PipelineText.empty() || PipelineText[0] == ')')
|
|
|
|
return true;
|
|
|
|
|
|
|
|
assert(PipelineText[0] == ',');
|
|
|
|
PipelineText = PipelineText.substr(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-01 07:40:05 +00:00
|
|
|
bool Passes::parseModulePassPipeline(ModulePassManager &MPM,
|
|
|
|
StringRef &PipelineText,
|
|
|
|
bool VerifyEachPass, bool DebugLogging) {
|
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
for (;;) {
|
|
|
|
// Parse nested pass managers by recursing.
|
|
|
|
if (PipelineText.startswith("module(")) {
|
2015-01-13 22:42:38 +00:00
|
|
|
ModulePassManager NestedMPM(DebugLogging);
|
2014-01-11 12:06:47 +00:00
|
|
|
|
|
|
|
// Parse the inner pipeline into the nested manager.
|
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
PipelineText = PipelineText.substr(strlen("module("));
|
2015-01-13 22:42:38 +00:00
|
|
|
if (!parseModulePassPipeline(NestedMPM, PipelineText, VerifyEachPass,
|
|
|
|
DebugLogging) ||
|
2014-01-12 10:02:02 +00:00
|
|
|
PipelineText.empty())
|
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
return false;
|
2014-01-12 10:02:02 +00:00
|
|
|
assert(PipelineText[0] == ')');
|
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
PipelineText = PipelineText.substr(1);
|
2014-01-11 12:06:47 +00:00
|
|
|
|
|
|
|
// Now add the nested manager as a module pass.
|
2014-03-09 11:49:53 +00:00
|
|
|
MPM.addPass(std::move(NestedMPM));
|
2014-04-21 11:12:00 +00:00
|
|
|
} else if (PipelineText.startswith("cgscc(")) {
|
2015-01-13 22:42:38 +00:00
|
|
|
CGSCCPassManager NestedCGPM(DebugLogging);
|
2014-04-21 11:12:00 +00:00
|
|
|
|
|
|
|
// Parse the inner pipeline inte the nested manager.
|
|
|
|
PipelineText = PipelineText.substr(strlen("cgscc("));
|
2015-01-13 22:42:38 +00:00
|
|
|
if (!parseCGSCCPassPipeline(NestedCGPM, PipelineText, VerifyEachPass,
|
|
|
|
DebugLogging) ||
|
2014-04-21 11:12:00 +00:00
|
|
|
PipelineText.empty())
|
|
|
|
return false;
|
|
|
|
assert(PipelineText[0] == ')');
|
|
|
|
PipelineText = PipelineText.substr(1);
|
|
|
|
|
|
|
|
// Add the nested pass manager with the appropriate adaptor.
|
|
|
|
MPM.addPass(
|
|
|
|
createModuleToPostOrderCGSCCPassAdaptor(std::move(NestedCGPM)));
|
2014-01-12 09:34:22 +00:00
|
|
|
} else if (PipelineText.startswith("function(")) {
|
2015-01-13 22:42:38 +00:00
|
|
|
FunctionPassManager NestedFPM(DebugLogging);
|
2014-01-12 09:34:22 +00:00
|
|
|
|
|
|
|
// Parse the inner pipeline inte the nested manager.
|
|
|
|
PipelineText = PipelineText.substr(strlen("function("));
|
2015-01-13 22:42:38 +00:00
|
|
|
if (!parseFunctionPassPipeline(NestedFPM, PipelineText, VerifyEachPass,
|
|
|
|
DebugLogging) ||
|
2014-01-12 10:02:02 +00:00
|
|
|
PipelineText.empty())
|
2014-01-12 09:34:22 +00:00
|
|
|
return false;
|
2014-01-12 10:02:02 +00:00
|
|
|
assert(PipelineText[0] == ')');
|
2014-01-12 09:34:22 +00:00
|
|
|
PipelineText = PipelineText.substr(1);
|
|
|
|
|
|
|
|
// Add the nested pass manager with the appropriate adaptor.
|
2014-03-09 11:49:53 +00:00
|
|
|
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(NestedFPM)));
|
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
} else {
|
|
|
|
// Otherwise try to parse a pass name.
|
|
|
|
size_t End = PipelineText.find_first_of(",)");
|
|
|
|
if (!parseModulePassName(MPM, PipelineText.substr(0, End)))
|
|
|
|
return false;
|
2014-01-20 11:34:08 +00:00
|
|
|
if (VerifyEachPass)
|
|
|
|
MPM.addPass(VerifierPass());
|
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
|
|
|
|
PipelineText = PipelineText.substr(End);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PipelineText.empty() || PipelineText[0] == ')')
|
|
|
|
return true;
|
|
|
|
|
|
|
|
assert(PipelineText[0] == ',');
|
|
|
|
PipelineText = PipelineText.substr(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Primary pass pipeline description parsing routine.
|
|
|
|
// FIXME: Should this routine accept a TargetMachine or require the caller to
|
|
|
|
// pre-populate the analysis managers with target-specific stuff?
|
2015-02-01 07:40:05 +00:00
|
|
|
bool Passes::parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText,
|
|
|
|
bool VerifyEachPass, bool DebugLogging) {
|
2015-01-06 08:37:58 +00:00
|
|
|
// By default, try to parse the pipeline as-if it were within an implicit
|
|
|
|
// 'module(...)' pass pipeline. If this will parse at all, it needs to
|
|
|
|
// consume the entire string.
|
2015-01-13 22:42:38 +00:00
|
|
|
if (parseModulePassPipeline(MPM, PipelineText, VerifyEachPass, DebugLogging))
|
2015-01-06 08:37:58 +00:00
|
|
|
return PipelineText.empty();
|
|
|
|
|
|
|
|
// This isn't parsable as a module pipeline, look for the end of a pass name
|
|
|
|
// and directly drop down to that layer.
|
2014-01-12 10:02:02 +00:00
|
|
|
StringRef FirstName =
|
|
|
|
PipelineText.substr(0, PipelineText.find_first_of(",)"));
|
2015-01-06 08:37:58 +00:00
|
|
|
assert(!isModulePassName(FirstName) &&
|
|
|
|
"Already handled all module pipeline options.");
|
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
|
2015-01-06 08:37:58 +00:00
|
|
|
// If this looks like a CGSCC pass, parse the whole thing as a CGSCC
|
|
|
|
// pipeline.
|
2014-04-21 11:12:00 +00:00
|
|
|
if (isCGSCCPassName(FirstName)) {
|
2015-01-13 22:42:38 +00:00
|
|
|
CGSCCPassManager CGPM(DebugLogging);
|
|
|
|
if (!parseCGSCCPassPipeline(CGPM, PipelineText, VerifyEachPass,
|
|
|
|
DebugLogging) ||
|
2014-04-21 11:12:00 +00:00
|
|
|
!PipelineText.empty())
|
|
|
|
return false;
|
|
|
|
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-01-06 08:37:58 +00:00
|
|
|
// Similarly, if this looks like a Function pass, parse the whole thing as
|
|
|
|
// a Function pipelien.
|
2014-01-12 09:34:22 +00:00
|
|
|
if (isFunctionPassName(FirstName)) {
|
2015-01-13 22:42:38 +00:00
|
|
|
FunctionPassManager FPM(DebugLogging);
|
|
|
|
if (!parseFunctionPassPipeline(FPM, PipelineText, VerifyEachPass,
|
|
|
|
DebugLogging) ||
|
2014-01-20 11:34:08 +00:00
|
|
|
!PipelineText.empty())
|
2014-01-12 09:34:22 +00:00
|
|
|
return false;
|
2014-03-09 11:49:53 +00:00
|
|
|
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
|
2014-01-12 09:34:22 +00:00
|
|
|
return true;
|
|
|
|
}
|
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198998 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-11 08:16:35 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|