mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-04 01:26:41 +00:00
[PM] Another post-commit fix in NewPMDriver
There were two errors in the parsing of opt's command line options for extension point pipelines. The EP callbacks are not supposed to return a value. To check the pipeline text for correctness, I now try to parse it into a temporary PM object, and print a message on failure. This solves the compile time error for the lambda return type, as well as correctly handles unparsable pipelines now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307649 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
301859ba89
commit
eb75f906da
@ -83,47 +83,64 @@ static cl::opt<std::string> VectorizerStartEPPipeline(
|
||||
cl::Hidden);
|
||||
/// @}}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/// 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) {
|
||||
if (!PeepholeEPPipeline.empty())
|
||||
if (tryParsePipelineText<FunctionPassManager>(PB, PeepholeEPPipeline))
|
||||
PB.registerPeepholeEPCallback([&PB, VerifyEachPass, DebugLogging](
|
||||
FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
|
||||
return PB.parsePassPipeline(PM, PeepholeEPPipeline, VerifyEachPass,
|
||||
DebugLogging);
|
||||
PB.parsePassPipeline(PM, PeepholeEPPipeline, VerifyEachPass,
|
||||
DebugLogging);
|
||||
});
|
||||
if (!LateLoopOptimizationsEPPipeline.empty())
|
||||
if (tryParsePipelineText<LoopPassManager>(PB,
|
||||
LateLoopOptimizationsEPPipeline))
|
||||
PB.registerLateLoopOptimizationsEPCallback(
|
||||
[&PB, VerifyEachPass, DebugLogging](
|
||||
LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
|
||||
return PB.parsePassPipeline(PM, LateLoopOptimizationsEPPipeline,
|
||||
VerifyEachPass, DebugLogging);
|
||||
PB.parsePassPipeline(PM, LateLoopOptimizationsEPPipeline,
|
||||
VerifyEachPass, DebugLogging);
|
||||
});
|
||||
if (!LoopOptimizerEndEPPipeline.empty())
|
||||
if (tryParsePipelineText<LoopPassManager>(PB, LoopOptimizerEndEPPipeline))
|
||||
PB.registerLoopOptimizerEndEPCallback([&PB, VerifyEachPass, DebugLogging](
|
||||
LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
|
||||
return PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline,
|
||||
VerifyEachPass, DebugLogging);
|
||||
PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline, VerifyEachPass,
|
||||
DebugLogging);
|
||||
});
|
||||
if (!ScalarOptimizerLateEPPipeline.empty())
|
||||
if (tryParsePipelineText<FunctionPassManager>(PB,
|
||||
ScalarOptimizerLateEPPipeline))
|
||||
PB.registerScalarOptimizerLateEPCallback(
|
||||
[&PB, VerifyEachPass, DebugLogging](
|
||||
FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
|
||||
return PB.parsePassPipeline(PM, ScalarOptimizerLateEPPipeline,
|
||||
VerifyEachPass, DebugLogging);
|
||||
PB.parsePassPipeline(PM, ScalarOptimizerLateEPPipeline,
|
||||
VerifyEachPass, DebugLogging);
|
||||
});
|
||||
if (!CGSCCOptimizerLateEPPipeline.empty())
|
||||
if (tryParsePipelineText<CGSCCPassManager>(PB, CGSCCOptimizerLateEPPipeline))
|
||||
PB.registerCGSCCOptimizerLateEPCallback([&PB, VerifyEachPass, DebugLogging](
|
||||
CGSCCPassManager &PM, PassBuilder::OptimizationLevel Level) {
|
||||
return PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline,
|
||||
VerifyEachPass, DebugLogging);
|
||||
PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline, VerifyEachPass,
|
||||
DebugLogging);
|
||||
});
|
||||
if (!VectorizerStartEPPipeline.empty())
|
||||
if (tryParsePipelineText<FunctionPassManager>(PB, VectorizerStartEPPipeline))
|
||||
PB.registerVectorizerStartEPCallback([&PB, VerifyEachPass, DebugLogging](
|
||||
FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
|
||||
return PB.parsePassPipeline(PM, VectorizerStartEPPipeline, VerifyEachPass,
|
||||
DebugLogging);
|
||||
PB.parsePassPipeline(PM, VectorizerStartEPPipeline, VerifyEachPass,
|
||||
DebugLogging);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user