diff options
author | Bob Wilson <bob.wilson@apple.com> | 2012-07-02 19:48:45 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2012-07-02 19:48:45 +0000 |
commit | cac3b9063320fdace01f1e994addf3b6823c8030 (patch) | |
tree | 5e7209428771ad7342d10bc57a6960d26b13b326 /llvm/lib/CodeGen/Passes.cpp | |
parent | a3f9fa710a0523b548ada0b700e525f0ae5f3520 (diff) | |
download | bcm5719-llvm-cac3b9063320fdace01f1e994addf3b6823c8030.tar.gz bcm5719-llvm-cac3b9063320fdace01f1e994addf3b6823c8030.zip |
Extend TargetPassConfig to allow running only a subset of the normal passes.
This is still a work in progress but I believe it is currently good enough
to fix PR13122 "Need unit test driver for codegen IR passes". For example,
you can run llc with -stop-after=loop-reduce to have it dump out the IR after
running LSR. Serializing machine-level IR is not yet supported but we have
some patches in progress for that.
The plan is to serialize the IR to a YAML file, containing separate sections
for the LLVM IR, machine-level IR, and whatever other info is needed. Chad
suggested that we stash the stop-after pass in the YAML file and use that
instead of the start-after option to figure out where to restart the
compilation. I think that's a great idea, but since it's not implemented yet
I put the -start-after option into this patch for testing purposes.
llvm-svn: 159570
Diffstat (limited to 'llvm/lib/CodeGen/Passes.cpp')
-rw-r--r-- | llvm/lib/CodeGen/Passes.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/Passes.cpp b/llvm/lib/CodeGen/Passes.cpp index 20a3ff45e85..1fefb9d45f4 100644 --- a/llvm/lib/CodeGen/Passes.cpp +++ b/llvm/lib/CodeGen/Passes.cpp @@ -213,7 +213,8 @@ TargetPassConfig::~TargetPassConfig() { // Out of line constructor provides default values for pass options and // registers all common codegen passes. TargetPassConfig::TargetPassConfig(TargetMachine *tm, PassManagerBase &pm) - : ImmutablePass(ID), PM(&pm), TM(tm), Impl(0), Initialized(false), + : ImmutablePass(ID), PM(&pm), StartAfter(0), StopAfter(0), + Started(true), Stopped(false), TM(tm), Impl(0), Initialized(false), DisableVerify(false), EnableTailMerge(true) { @@ -271,11 +272,22 @@ AnalysisID TargetPassConfig::getPassSubstitution(AnalysisID ID) const { return I->second; } -/// Add a pass to the PassManager. +/// Add a pass to the PassManager if that pass is supposed to be run. If the +/// Started/Stopped flags indicate either that the compilation should start at +/// a later pass or that it should stop after an earlier pass, then do not add +/// the pass. Finally, compare the current pass against the StartAfter +/// and StopAfter options and change the Started/Stopped flags accordingly. void TargetPassConfig::addPass(Pass *P) { assert(!Initialized && "PassConfig is immutable"); - PM->add(P); + if (Started && !Stopped) + PM->add(P); + if (StopAfter == P->getPassID()) + Stopped = true; + if (StartAfter == P->getPassID()) + Started = true; + if (Stopped && !Started) + report_fatal_error("Cannot stop compilation after pass that is not run"); } /// Add a CodeGen pass at this point in the pipeline after checking for target |