llvm.org GIT mirror llvm / eb75f90
[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 Philip Pfaffe 3 years ago
1 changed file(s) with 38 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
8282 cl::Hidden);
8383 /// @}}
8484
85 template
86 bool tryParsePipelineText(PassBuilder &PB, StringRef PipelineText) {
87 if (PipelineText.empty())
88 return false;
89
90 // Verify the pipeline is parseable:
91 PassManagerT PM;
92 if (PB.parsePassPipeline(PM, PipelineText))
93 return true;
94
95 errs() << "Could not parse pipeline '" << PipelineText
96 << "'. I'm going to igore it.\n";
97 return false;
98 }
99
85100 /// If one of the EPPipeline command line options was given, register callbacks
86101 /// for parsing and inserting the given pipeline
87102 static void registerEPCallbacks(PassBuilder &PB, bool VerifyEachPass,
88103 bool DebugLogging) {
89 if (!PeepholeEPPipeline.empty())
104 if (tryParsePipelineText(PB, PeepholeEPPipeline))
90105 PB.registerPeepholeEPCallback([&PB, VerifyEachPass, DebugLogging](
91106 FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
92 return PB.parsePassPipeline(PM, PeepholeEPPipeline, VerifyEachPass,
93 DebugLogging);
94 });
95 if (!LateLoopOptimizationsEPPipeline.empty())
107 PB.parsePassPipeline(PM, PeepholeEPPipeline, VerifyEachPass,
108 DebugLogging);
109 });
110 if (tryParsePipelineText(PB,
111 LateLoopOptimizationsEPPipeline))
96112 PB.registerLateLoopOptimizationsEPCallback(
97113 [&PB, VerifyEachPass, DebugLogging](
98114 LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
99 return PB.parsePassPipeline(PM, LateLoopOptimizationsEPPipeline,
100 VerifyEachPass, DebugLogging);
115 PB.parsePassPipeline(PM, LateLoopOptimizationsEPPipeline,
116 VerifyEachPass, DebugLogging);
101117 });
102 if (!LoopOptimizerEndEPPipeline.empty())
118 if (tryParsePipelineText(PB, LoopOptimizerEndEPPipeline))
103119 PB.registerLoopOptimizerEndEPCallback([&PB, VerifyEachPass, DebugLogging](
104120 LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
105 return PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline,
106 VerifyEachPass, DebugLogging);
107 });
108 if (!ScalarOptimizerLateEPPipeline.empty())
121 PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline, VerifyEachPass,
122 DebugLogging);
123 });
124 if (tryParsePipelineText(PB,
125 ScalarOptimizerLateEPPipeline))
109126 PB.registerScalarOptimizerLateEPCallback(
110127 [&PB, VerifyEachPass, DebugLogging](
111128 FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
112 return PB.parsePassPipeline(PM, ScalarOptimizerLateEPPipeline,
113 VerifyEachPass, DebugLogging);
129 PB.parsePassPipeline(PM, ScalarOptimizerLateEPPipeline,
130 VerifyEachPass, DebugLogging);
114131 });
115 if (!CGSCCOptimizerLateEPPipeline.empty())
132 if (tryParsePipelineText(PB, CGSCCOptimizerLateEPPipeline))
116133 PB.registerCGSCCOptimizerLateEPCallback([&PB, VerifyEachPass, DebugLogging](
117134 CGSCCPassManager &PM, PassBuilder::OptimizationLevel Level) {
118 return PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline,
119 VerifyEachPass, DebugLogging);
120 });
121 if (!VectorizerStartEPPipeline.empty())
135 PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline, VerifyEachPass,
136 DebugLogging);
137 });
138 if (tryParsePipelineText(PB, VectorizerStartEPPipeline))
122139 PB.registerVectorizerStartEPCallback([&PB, VerifyEachPass, DebugLogging](
123140 FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
124 return PB.parsePassPipeline(PM, VectorizerStartEPPipeline, VerifyEachPass,
125 DebugLogging);
141 PB.parsePassPipeline(PM, VectorizerStartEPPipeline, VerifyEachPass,
142 DebugLogging);
126143 });
127144 }
128145