blob: ee51543055474411d514810b0b766cf9bb582f95 [file] [log] [blame]
Chandler Carruth66445382014-01-11 08:16:35 +00001//===- Passes.cpp - Parsing, selection, and running of passes -------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9/// \file
10///
11/// This file provides the infrastructure to parse and build a custom pass
12/// manager based on a commandline flag. It also provides helpers to aid in
13/// analyzing, debugging, and testing pass structures.
14///
15//===----------------------------------------------------------------------===//
16
17#include "Passes.h"
Chandler Carruth572e3402014-04-21 11:12:00 +000018#include "llvm/Analysis/CGSCCPassManager.h"
Chandler Carruthbf71a342014-02-06 04:37:03 +000019#include "llvm/Analysis/LazyCallGraph.h"
Chandler Carruthaaf0b4c2015-01-20 10:58:50 +000020#include "llvm/Analysis/LoopInfo.h"
Chandler Carruth8ca43222015-01-15 11:39:46 +000021#include "llvm/Analysis/TargetLibraryInfo.h"
Chandler Carruth64764b42015-01-14 10:19:28 +000022#include "llvm/IR/Dominators.h"
Chandler Carruth52eef882014-01-12 12:15:39 +000023#include "llvm/IR/IRPrintingPasses.h"
Chandler Carruth66445382014-01-11 08:16:35 +000024#include "llvm/IR/PassManager.h"
Chandler Carruth4d356312014-01-20 11:34:08 +000025#include "llvm/IR/Verifier.h"
Chandler Carruth52eef882014-01-12 12:15:39 +000026#include "llvm/Support/Debug.h"
Chandler Carruth66445382014-01-11 08:16:35 +000027
28using namespace llvm;
29
30namespace {
31
Chandler Carruthd8330982014-01-12 09:34:22 +000032/// \brief No-op module pass which does nothing.
Chandler Carruth66445382014-01-11 08:16:35 +000033struct NoOpModulePass {
Chandler Carruthd174ce42015-01-05 02:47:05 +000034 PreservedAnalyses run(Module &M) { return PreservedAnalyses::all(); }
Chandler Carrutha13f27c2014-01-11 11:52:05 +000035 static StringRef name() { return "NoOpModulePass"; }
Chandler Carruth66445382014-01-11 08:16:35 +000036};
37
Chandler Carruth0b576b32015-01-06 02:50:06 +000038/// \brief No-op module analysis.
39struct NoOpModuleAnalysis {
40 struct Result {};
41 Result run(Module &) { return Result(); }
42 static StringRef name() { return "NoOpModuleAnalysis"; }
43 static void *ID() { return (void *)&PassID; }
44private:
45 static char PassID;
46};
47
48char NoOpModuleAnalysis::PassID;
49
Chandler Carruth572e3402014-04-21 11:12:00 +000050/// \brief No-op CGSCC pass which does nothing.
51struct NoOpCGSCCPass {
Chandler Carruthd174ce42015-01-05 02:47:05 +000052 PreservedAnalyses run(LazyCallGraph::SCC &C) {
Chandler Carruth572e3402014-04-21 11:12:00 +000053 return PreservedAnalyses::all();
54 }
55 static StringRef name() { return "NoOpCGSCCPass"; }
56};
57
Chandler Carruth0b576b32015-01-06 02:50:06 +000058/// \brief No-op CGSCC analysis.
59struct NoOpCGSCCAnalysis {
60 struct Result {};
61 Result run(LazyCallGraph::SCC &) { return Result(); }
62 static StringRef name() { return "NoOpCGSCCAnalysis"; }
63 static void *ID() { return (void *)&PassID; }
64private:
65 static char PassID;
66};
67
68char NoOpCGSCCAnalysis::PassID;
69
Chandler Carruthd8330982014-01-12 09:34:22 +000070/// \brief No-op function pass which does nothing.
71struct NoOpFunctionPass {
Chandler Carruthd174ce42015-01-05 02:47:05 +000072 PreservedAnalyses run(Function &F) { return PreservedAnalyses::all(); }
Chandler Carruthd8330982014-01-12 09:34:22 +000073 static StringRef name() { return "NoOpFunctionPass"; }
74};
75
Chandler Carruth0b576b32015-01-06 02:50:06 +000076/// \brief No-op function analysis.
77struct NoOpFunctionAnalysis {
78 struct Result {};
79 Result run(Function &) { return Result(); }
80 static StringRef name() { return "NoOpFunctionAnalysis"; }
81 static void *ID() { return (void *)&PassID; }
82private:
83 static char PassID;
84};
85
86char NoOpFunctionAnalysis::PassID;
87
Chandler Carruth66445382014-01-11 08:16:35 +000088} // End anonymous namespace.
89
Chandler Carruthb70f6732015-01-06 02:21:37 +000090void llvm::registerModuleAnalyses(ModuleAnalysisManager &MAM) {
91#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
92 MAM.registerPass(CREATE_PASS);
93#include "PassRegistry.def"
94}
95
96void llvm::registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM) {
97#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
98 CGAM.registerPass(CREATE_PASS);
99#include "PassRegistry.def"
100}
101
102void llvm::registerFunctionAnalyses(FunctionAnalysisManager &FAM) {
103#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
104 FAM.registerPass(CREATE_PASS);
105#include "PassRegistry.def"
106}
107
Chandler Carruth9d2e58f2015-01-06 09:10:47 +0000108#ifndef NDEBUG
Chandler Carruth66445382014-01-11 08:16:35 +0000109static bool isModulePassName(StringRef Name) {
Chandler Carruth58944182014-04-21 08:08:50 +0000110#define MODULE_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
Chandler Carruth628503e2015-01-06 02:10:51 +0000111#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000112 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
Chandler Carruth628503e2015-01-06 02:10:51 +0000113 return true;
114#include "PassRegistry.def"
115
Chandler Carruth66445382014-01-11 08:16:35 +0000116 return false;
117}
Chandler Carruth9d2e58f2015-01-06 09:10:47 +0000118#endif
Chandler Carruth66445382014-01-11 08:16:35 +0000119
Chandler Carruth572e3402014-04-21 11:12:00 +0000120static bool isCGSCCPassName(StringRef Name) {
Chandler Carruth572e3402014-04-21 11:12:00 +0000121#define CGSCC_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
Chandler Carruth628503e2015-01-06 02:10:51 +0000122#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000123 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
Chandler Carruth628503e2015-01-06 02:10:51 +0000124 return true;
125#include "PassRegistry.def"
126
Chandler Carruth572e3402014-04-21 11:12:00 +0000127 return false;
128}
129
Chandler Carruthd8330982014-01-12 09:34:22 +0000130static bool isFunctionPassName(StringRef Name) {
Chandler Carruth58944182014-04-21 08:08:50 +0000131#define FUNCTION_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
Chandler Carruth628503e2015-01-06 02:10:51 +0000132#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000133 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
Chandler Carruth628503e2015-01-06 02:10:51 +0000134 return true;
135#include "PassRegistry.def"
136
Chandler Carruthd8330982014-01-12 09:34:22 +0000137 return false;
138}
139
Chandler Carruth66445382014-01-11 08:16:35 +0000140static bool parseModulePassName(ModulePassManager &MPM, StringRef Name) {
Chandler Carruth58944182014-04-21 08:08:50 +0000141#define MODULE_PASS(NAME, CREATE_PASS) \
142 if (Name == NAME) { \
143 MPM.addPass(CREATE_PASS); \
144 return true; \
Chandler Carruth52eef882014-01-12 12:15:39 +0000145 }
Chandler Carruth628503e2015-01-06 02:10:51 +0000146#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
147 if (Name == "require<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000148 MPM.addPass(RequireAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth628503e2015-01-06 02:10:51 +0000149 return true; \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000150 } \
151 if (Name == "invalidate<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000152 MPM.addPass(InvalidateAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000153 return true; \
Chandler Carruth628503e2015-01-06 02:10:51 +0000154 }
155#include "PassRegistry.def"
156
Chandler Carruth66445382014-01-11 08:16:35 +0000157 return false;
158}
159
Chandler Carruth572e3402014-04-21 11:12:00 +0000160static bool parseCGSCCPassName(CGSCCPassManager &CGPM, StringRef Name) {
Chandler Carruth572e3402014-04-21 11:12:00 +0000161#define CGSCC_PASS(NAME, CREATE_PASS) \
162 if (Name == NAME) { \
163 CGPM.addPass(CREATE_PASS); \
164 return true; \
165 }
Chandler Carruth628503e2015-01-06 02:10:51 +0000166#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
167 if (Name == "require<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000168 CGPM.addPass(RequireAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth628503e2015-01-06 02:10:51 +0000169 return true; \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000170 } \
171 if (Name == "invalidate<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000172 CGPM.addPass(InvalidateAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000173 return true; \
Chandler Carruth628503e2015-01-06 02:10:51 +0000174 }
175#include "PassRegistry.def"
176
Chandler Carruth572e3402014-04-21 11:12:00 +0000177 return false;
178}
179
Chandler Carruthd8330982014-01-12 09:34:22 +0000180static bool parseFunctionPassName(FunctionPassManager &FPM, StringRef Name) {
Chandler Carruth58944182014-04-21 08:08:50 +0000181#define FUNCTION_PASS(NAME, CREATE_PASS) \
182 if (Name == NAME) { \
183 FPM.addPass(CREATE_PASS); \
184 return true; \
Chandler Carruth52eef882014-01-12 12:15:39 +0000185 }
Chandler Carruth628503e2015-01-06 02:10:51 +0000186#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
187 if (Name == "require<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000188 FPM.addPass(RequireAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth628503e2015-01-06 02:10:51 +0000189 return true; \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000190 } \
191 if (Name == "invalidate<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000192 FPM.addPass(InvalidateAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000193 return true; \
Chandler Carruth628503e2015-01-06 02:10:51 +0000194 }
195#include "PassRegistry.def"
196
Chandler Carruthd8330982014-01-12 09:34:22 +0000197 return false;
198}
199
200static bool parseFunctionPassPipeline(FunctionPassManager &FPM,
Chandler Carruth4d356312014-01-20 11:34:08 +0000201 StringRef &PipelineText,
Chandler Carruth14a759e2015-01-13 22:42:38 +0000202 bool VerifyEachPass, bool DebugLogging) {
Chandler Carruthd8330982014-01-12 09:34:22 +0000203 for (;;) {
204 // Parse nested pass managers by recursing.
205 if (PipelineText.startswith("function(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000206 FunctionPassManager NestedFPM(DebugLogging);
Chandler Carruthd8330982014-01-12 09:34:22 +0000207
208 // Parse the inner pipeline inte the nested manager.
209 PipelineText = PipelineText.substr(strlen("function("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000210 if (!parseFunctionPassPipeline(NestedFPM, PipelineText, VerifyEachPass,
211 DebugLogging) ||
Chandler Carruth6546cb62014-01-12 10:02:02 +0000212 PipelineText.empty())
Chandler Carruthd8330982014-01-12 09:34:22 +0000213 return false;
Chandler Carruth6546cb62014-01-12 10:02:02 +0000214 assert(PipelineText[0] == ')');
Chandler Carruthd8330982014-01-12 09:34:22 +0000215 PipelineText = PipelineText.substr(1);
216
217 // Add the nested pass manager with the appropriate adaptor.
Chandler Carruthc3f3da32014-03-09 11:49:53 +0000218 FPM.addPass(std::move(NestedFPM));
Chandler Carruthd8330982014-01-12 09:34:22 +0000219 } else {
220 // Otherwise try to parse a pass name.
221 size_t End = PipelineText.find_first_of(",)");
222 if (!parseFunctionPassName(FPM, PipelineText.substr(0, End)))
223 return false;
Chandler Carruth4d356312014-01-20 11:34:08 +0000224 if (VerifyEachPass)
225 FPM.addPass(VerifierPass());
Chandler Carruthd8330982014-01-12 09:34:22 +0000226
227 PipelineText = PipelineText.substr(End);
228 }
229
230 if (PipelineText.empty() || PipelineText[0] == ')')
231 return true;
232
233 assert(PipelineText[0] == ',');
234 PipelineText = PipelineText.substr(1);
235 }
236}
237
Chandler Carruth572e3402014-04-21 11:12:00 +0000238static bool parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
Chandler Carruth14a759e2015-01-13 22:42:38 +0000239 StringRef &PipelineText, bool VerifyEachPass,
240 bool DebugLogging) {
Chandler Carruth572e3402014-04-21 11:12:00 +0000241 for (;;) {
242 // Parse nested pass managers by recursing.
243 if (PipelineText.startswith("cgscc(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000244 CGSCCPassManager NestedCGPM(DebugLogging);
Chandler Carruth572e3402014-04-21 11:12:00 +0000245
246 // Parse the inner pipeline into the nested manager.
247 PipelineText = PipelineText.substr(strlen("cgscc("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000248 if (!parseCGSCCPassPipeline(NestedCGPM, PipelineText, VerifyEachPass,
249 DebugLogging) ||
Chandler Carruth572e3402014-04-21 11:12:00 +0000250 PipelineText.empty())
251 return false;
252 assert(PipelineText[0] == ')');
253 PipelineText = PipelineText.substr(1);
254
255 // Add the nested pass manager with the appropriate adaptor.
256 CGPM.addPass(std::move(NestedCGPM));
257 } else if (PipelineText.startswith("function(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000258 FunctionPassManager NestedFPM(DebugLogging);
Chandler Carruth572e3402014-04-21 11:12:00 +0000259
260 // Parse the inner pipeline inte the nested manager.
261 PipelineText = PipelineText.substr(strlen("function("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000262 if (!parseFunctionPassPipeline(NestedFPM, PipelineText, VerifyEachPass,
263 DebugLogging) ||
Chandler Carruth572e3402014-04-21 11:12:00 +0000264 PipelineText.empty())
265 return false;
266 assert(PipelineText[0] == ')');
267 PipelineText = PipelineText.substr(1);
268
269 // Add the nested pass manager with the appropriate adaptor.
270 CGPM.addPass(createCGSCCToFunctionPassAdaptor(std::move(NestedFPM)));
271 } else {
272 // Otherwise try to parse a pass name.
273 size_t End = PipelineText.find_first_of(",)");
274 if (!parseCGSCCPassName(CGPM, PipelineText.substr(0, End)))
275 return false;
276 // FIXME: No verifier support for CGSCC passes!
277
278 PipelineText = PipelineText.substr(End);
279 }
280
281 if (PipelineText.empty() || PipelineText[0] == ')')
282 return true;
283
284 assert(PipelineText[0] == ',');
285 PipelineText = PipelineText.substr(1);
286 }
287}
288
Chandler Carruth66445382014-01-11 08:16:35 +0000289static bool parseModulePassPipeline(ModulePassManager &MPM,
Chandler Carruth4d356312014-01-20 11:34:08 +0000290 StringRef &PipelineText,
Chandler Carruth14a759e2015-01-13 22:42:38 +0000291 bool VerifyEachPass, bool DebugLogging) {
Chandler Carruth66445382014-01-11 08:16:35 +0000292 for (;;) {
293 // Parse nested pass managers by recursing.
294 if (PipelineText.startswith("module(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000295 ModulePassManager NestedMPM(DebugLogging);
Chandler Carruth258dbb32014-01-11 12:06:47 +0000296
297 // Parse the inner pipeline into the nested manager.
Chandler Carruth66445382014-01-11 08:16:35 +0000298 PipelineText = PipelineText.substr(strlen("module("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000299 if (!parseModulePassPipeline(NestedMPM, PipelineText, VerifyEachPass,
300 DebugLogging) ||
Chandler Carruth6546cb62014-01-12 10:02:02 +0000301 PipelineText.empty())
Chandler Carruth66445382014-01-11 08:16:35 +0000302 return false;
Chandler Carruth6546cb62014-01-12 10:02:02 +0000303 assert(PipelineText[0] == ')');
Chandler Carruth66445382014-01-11 08:16:35 +0000304 PipelineText = PipelineText.substr(1);
Chandler Carruth258dbb32014-01-11 12:06:47 +0000305
306 // Now add the nested manager as a module pass.
Chandler Carruthc3f3da32014-03-09 11:49:53 +0000307 MPM.addPass(std::move(NestedMPM));
Chandler Carruth572e3402014-04-21 11:12:00 +0000308 } else if (PipelineText.startswith("cgscc(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000309 CGSCCPassManager NestedCGPM(DebugLogging);
Chandler Carruth572e3402014-04-21 11:12:00 +0000310
311 // Parse the inner pipeline inte the nested manager.
312 PipelineText = PipelineText.substr(strlen("cgscc("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000313 if (!parseCGSCCPassPipeline(NestedCGPM, PipelineText, VerifyEachPass,
314 DebugLogging) ||
Chandler Carruth572e3402014-04-21 11:12:00 +0000315 PipelineText.empty())
316 return false;
317 assert(PipelineText[0] == ')');
318 PipelineText = PipelineText.substr(1);
319
320 // Add the nested pass manager with the appropriate adaptor.
321 MPM.addPass(
322 createModuleToPostOrderCGSCCPassAdaptor(std::move(NestedCGPM)));
Chandler Carruthd8330982014-01-12 09:34:22 +0000323 } else if (PipelineText.startswith("function(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000324 FunctionPassManager NestedFPM(DebugLogging);
Chandler Carruthd8330982014-01-12 09:34:22 +0000325
326 // Parse the inner pipeline inte the nested manager.
327 PipelineText = PipelineText.substr(strlen("function("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000328 if (!parseFunctionPassPipeline(NestedFPM, PipelineText, VerifyEachPass,
329 DebugLogging) ||
Chandler Carruth6546cb62014-01-12 10:02:02 +0000330 PipelineText.empty())
Chandler Carruthd8330982014-01-12 09:34:22 +0000331 return false;
Chandler Carruth6546cb62014-01-12 10:02:02 +0000332 assert(PipelineText[0] == ')');
Chandler Carruthd8330982014-01-12 09:34:22 +0000333 PipelineText = PipelineText.substr(1);
334
335 // Add the nested pass manager with the appropriate adaptor.
Chandler Carruthc3f3da32014-03-09 11:49:53 +0000336 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(NestedFPM)));
Chandler Carruth66445382014-01-11 08:16:35 +0000337 } else {
338 // Otherwise try to parse a pass name.
339 size_t End = PipelineText.find_first_of(",)");
340 if (!parseModulePassName(MPM, PipelineText.substr(0, End)))
341 return false;
Chandler Carruth4d356312014-01-20 11:34:08 +0000342 if (VerifyEachPass)
343 MPM.addPass(VerifierPass());
Chandler Carruth66445382014-01-11 08:16:35 +0000344
345 PipelineText = PipelineText.substr(End);
346 }
347
348 if (PipelineText.empty() || PipelineText[0] == ')')
349 return true;
350
351 assert(PipelineText[0] == ',');
352 PipelineText = PipelineText.substr(1);
353 }
354}
355
356// Primary pass pipeline description parsing routine.
357// FIXME: Should this routine accept a TargetMachine or require the caller to
358// pre-populate the analysis managers with target-specific stuff?
Chandler Carruth4d356312014-01-20 11:34:08 +0000359bool llvm::parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText,
Chandler Carruth14a759e2015-01-13 22:42:38 +0000360 bool VerifyEachPass, bool DebugLogging) {
Chandler Carruthea368f12015-01-06 08:37:58 +0000361 // By default, try to parse the pipeline as-if it were within an implicit
362 // 'module(...)' pass pipeline. If this will parse at all, it needs to
363 // consume the entire string.
Chandler Carruth14a759e2015-01-13 22:42:38 +0000364 if (parseModulePassPipeline(MPM, PipelineText, VerifyEachPass, DebugLogging))
Chandler Carruthea368f12015-01-06 08:37:58 +0000365 return PipelineText.empty();
Chandler Carruth66445382014-01-11 08:16:35 +0000366
Chandler Carruthea368f12015-01-06 08:37:58 +0000367 // This isn't parsable as a module pipeline, look for the end of a pass name
368 // and directly drop down to that layer.
Chandler Carruth6546cb62014-01-12 10:02:02 +0000369 StringRef FirstName =
370 PipelineText.substr(0, PipelineText.find_first_of(",)"));
Chandler Carruthea368f12015-01-06 08:37:58 +0000371 assert(!isModulePassName(FirstName) &&
372 "Already handled all module pipeline options.");
Chandler Carruth66445382014-01-11 08:16:35 +0000373
Chandler Carruthea368f12015-01-06 08:37:58 +0000374 // If this looks like a CGSCC pass, parse the whole thing as a CGSCC
375 // pipeline.
Chandler Carruth572e3402014-04-21 11:12:00 +0000376 if (isCGSCCPassName(FirstName)) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000377 CGSCCPassManager CGPM(DebugLogging);
378 if (!parseCGSCCPassPipeline(CGPM, PipelineText, VerifyEachPass,
379 DebugLogging) ||
Chandler Carruth572e3402014-04-21 11:12:00 +0000380 !PipelineText.empty())
381 return false;
382 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
383 return true;
384 }
385
Chandler Carruthea368f12015-01-06 08:37:58 +0000386 // Similarly, if this looks like a Function pass, parse the whole thing as
387 // a Function pipelien.
Chandler Carruthd8330982014-01-12 09:34:22 +0000388 if (isFunctionPassName(FirstName)) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000389 FunctionPassManager FPM(DebugLogging);
390 if (!parseFunctionPassPipeline(FPM, PipelineText, VerifyEachPass,
391 DebugLogging) ||
Chandler Carruth4d356312014-01-20 11:34:08 +0000392 !PipelineText.empty())
Chandler Carruthd8330982014-01-12 09:34:22 +0000393 return false;
Chandler Carruthc3f3da32014-03-09 11:49:53 +0000394 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
Chandler Carruthd8330982014-01-12 09:34:22 +0000395 return true;
396 }
Chandler Carruth66445382014-01-11 08:16:35 +0000397
398 return false;
399}