mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-24 04:45:00 +00:00
[llc] Add support for several run-pass options.
Previously we could run only one machine pass with the run-pass option. With that patch, we can now specify several passes with several run-pass options (or just one option with a list of comma separated passes) and llc will build the related pipeline. This is great to test the interaction of two passes that are not necessarily next to each other in the pipeline, or play with pass ordering. Now, we should be at parity with opt for the flexibility of running passes. Note: I also moved the run pass option from CommandFlags.h to llc.cpp because, really, this is needed only there! llvm-svn: 272356
This commit is contained in:
parent
b4c774b3be
commit
3866bb8809
@ -230,10 +230,6 @@ cl::opt<std::string> StartAfter("start-after",
|
|||||||
cl::value_desc("pass-name"),
|
cl::value_desc("pass-name"),
|
||||||
cl::init(""));
|
cl::init(""));
|
||||||
|
|
||||||
cl::opt<std::string>
|
|
||||||
RunPass("run-pass", cl::desc("Run compiler only for one specific pass"),
|
|
||||||
cl::value_desc("pass-name"), cl::init(""));
|
|
||||||
|
|
||||||
cl::opt<bool> DataSections("data-sections",
|
cl::opt<bool> DataSections("data-sections",
|
||||||
cl::desc("Emit data into separate sections"),
|
cl::desc("Emit data into separate sections"),
|
||||||
cl::init(false));
|
cl::init(false));
|
||||||
|
20
test/CodeGen/MIR/Generic/multiRunPass.mir
Normal file
20
test/CodeGen/MIR/Generic/multiRunPass.mir
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# RUN: llc -run-pass expand-isel-pseudos -run-pass peephole-opts -debug-pass=Arguments -o /dev/null %s 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=PSEUDO_PEEPHOLE
|
||||||
|
# RUN: llc -run-pass expand-isel-pseudos,peephole-opts -debug-pass=Arguments -o /dev/null %s 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=PSEUDO_PEEPHOLE
|
||||||
|
# RUN: llc -run-pass peephole-opts -run-pass expand-isel-pseudos -debug-pass=Arguments -o /dev/null %s 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=PEEPHOLE_PSEUDO
|
||||||
|
# RUN: llc -run-pass peephole-opts,expand-isel-pseudos -debug-pass=Arguments -o /dev/null %s 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=PEEPHOLE_PSEUDO
|
||||||
|
# REQUIRES: asserts
|
||||||
|
|
||||||
|
# This test ensures that the command line accepts
|
||||||
|
# several run passes on the same command line and
|
||||||
|
# actually create the proper pipeline for it.
|
||||||
|
# PSEUDO_PEEPHOLE: -expand-isel-pseudos -peephole-opts
|
||||||
|
# PEEPHOLE_PSEUDO: -peephole-opts -expand-isel-pseudos
|
||||||
|
|
||||||
|
# Make sure there are no other passes happening after what we asked.
|
||||||
|
# CHECK-NEXT: --- |
|
||||||
|
---
|
||||||
|
# CHECK: name: foo
|
||||||
|
name: foo
|
||||||
|
body: |
|
||||||
|
bb.0:
|
||||||
|
...
|
@ -118,6 +118,28 @@ static cl::opt<bool> ExitOnError(
|
|||||||
cl::desc("Exit as soon as an error is encountered."),
|
cl::desc("Exit as soon as an error is encountered."),
|
||||||
cl::init(false), cl::Hidden);
|
cl::init(false), cl::Hidden);
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
static ManagedStatic<std::vector<std::string>> RunPassNames;
|
||||||
|
|
||||||
|
struct RunPassOption {
|
||||||
|
void operator=(const std::string &Val) const {
|
||||||
|
if (Val.empty())
|
||||||
|
return;
|
||||||
|
SmallVector<StringRef, 8> PassNames;
|
||||||
|
StringRef(Val).split(PassNames, ',', -1, false);
|
||||||
|
for (auto PassName : PassNames)
|
||||||
|
RunPassNames->push_back(PassName);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static RunPassOption RunPassOpt;
|
||||||
|
|
||||||
|
static cl::opt<RunPassOption, true, cl::parser<std::string>> RunPass(
|
||||||
|
"run-pass",
|
||||||
|
cl::desc("Run compiler only for specified passes (comma separated list)"),
|
||||||
|
cl::value_desc("pass-name"), cl::ZeroOrMore, cl::location(RunPassOpt));
|
||||||
|
|
||||||
static int compileModule(char **, LLVMContext &);
|
static int compileModule(char **, LLVMContext &);
|
||||||
|
|
||||||
static std::unique_ptr<tool_output_file>
|
static std::unique_ptr<tool_output_file>
|
||||||
@ -379,7 +401,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
|
|||||||
AnalysisID StartAfterID = nullptr;
|
AnalysisID StartAfterID = nullptr;
|
||||||
AnalysisID StopAfterID = nullptr;
|
AnalysisID StopAfterID = nullptr;
|
||||||
const PassRegistry *PR = PassRegistry::getPassRegistry();
|
const PassRegistry *PR = PassRegistry::getPassRegistry();
|
||||||
if (!RunPass.empty()) {
|
if (!RunPassNames->empty()) {
|
||||||
if (!StartAfter.empty() || !StopAfter.empty()) {
|
if (!StartAfter.empty() || !StopAfter.empty()) {
|
||||||
errs() << argv[0] << ": start-after and/or stop-after passes are "
|
errs() << argv[0] << ": start-after and/or stop-after passes are "
|
||||||
"redundant when run-pass is specified.\n";
|
"redundant when run-pass is specified.\n";
|
||||||
@ -389,9 +411,10 @@ static int compileModule(char **argv, LLVMContext &Context) {
|
|||||||
errs() << argv[0] << ": run-pass needs a .mir input.\n";
|
errs() << argv[0] << ": run-pass needs a .mir input.\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
const PassInfo *PI = PR->getPassInfo(RunPass);
|
for (std::string &RunPassName : *RunPassNames) {
|
||||||
|
const PassInfo *PI = PR->getPassInfo(RunPassName);
|
||||||
if (!PI) {
|
if (!PI) {
|
||||||
errs() << argv[0] << ": run-pass pass is not registered.\n";
|
errs() << argv[0] << ": run-pass " << RunPassName << " is not registered.\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
LLVMTargetMachine &LLVMTM = static_cast<LLVMTargetMachine&>(*Target);
|
LLVMTargetMachine &LLVMTM = static_cast<LLVMTargetMachine&>(*Target);
|
||||||
@ -415,7 +438,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
|
|||||||
= std::string("After ") + std::string(P->getPassName());
|
= std::string("After ") + std::string(P->getPassName());
|
||||||
PM.add(P);
|
PM.add(P);
|
||||||
TPC->printAndVerify(Banner);
|
TPC->printAndVerify(Banner);
|
||||||
|
}
|
||||||
PM.add(createPrintMIRPass(errs()));
|
PM.add(createPrintMIRPass(errs()));
|
||||||
} else {
|
} else {
|
||||||
if (!StartAfter.empty()) {
|
if (!StartAfter.empty()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user