blob: 5488059905e51282ab2823e3ed6d0b492e390251 [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 Carruthdf8b2232015-01-22 21:53:09 +000018#include "llvm/Analysis/AssumptionCache.h"
Chandler Carruth572e3402014-04-21 11:12:00 +000019#include "llvm/Analysis/CGSCCPassManager.h"
Chandler Carruthbf71a342014-02-06 04:37:03 +000020#include "llvm/Analysis/LazyCallGraph.h"
Chandler Carruthaaf0b4c2015-01-20 10:58:50 +000021#include "llvm/Analysis/LoopInfo.h"
Chandler Carruth8ca43222015-01-15 11:39:46 +000022#include "llvm/Analysis/TargetLibraryInfo.h"
Chandler Carruth64764b42015-01-14 10:19:28 +000023#include "llvm/IR/Dominators.h"
Chandler Carruth52eef882014-01-12 12:15:39 +000024#include "llvm/IR/IRPrintingPasses.h"
Chandler Carruth66445382014-01-11 08:16:35 +000025#include "llvm/IR/PassManager.h"
Chandler Carruth4d356312014-01-20 11:34:08 +000026#include "llvm/IR/Verifier.h"
Chandler Carruth52eef882014-01-12 12:15:39 +000027#include "llvm/Support/Debug.h"
Chandler Carruth66445382014-01-11 08:16:35 +000028
29using namespace llvm;
30
31namespace {
32
Chandler Carruthd8330982014-01-12 09:34:22 +000033/// \brief No-op module pass which does nothing.
Chandler Carruth66445382014-01-11 08:16:35 +000034struct NoOpModulePass {
Chandler Carruthd174ce42015-01-05 02:47:05 +000035 PreservedAnalyses run(Module &M) { return PreservedAnalyses::all(); }
Chandler Carrutha13f27c2014-01-11 11:52:05 +000036 static StringRef name() { return "NoOpModulePass"; }
Chandler Carruth66445382014-01-11 08:16:35 +000037};
38
Chandler Carruth0b576b32015-01-06 02:50:06 +000039/// \brief No-op module analysis.
40struct NoOpModuleAnalysis {
41 struct Result {};
42 Result run(Module &) { return Result(); }
43 static StringRef name() { return "NoOpModuleAnalysis"; }
44 static void *ID() { return (void *)&PassID; }
45private:
46 static char PassID;
47};
48
49char NoOpModuleAnalysis::PassID;
50
Chandler Carruth572e3402014-04-21 11:12:00 +000051/// \brief No-op CGSCC pass which does nothing.
52struct NoOpCGSCCPass {
Chandler Carruthd174ce42015-01-05 02:47:05 +000053 PreservedAnalyses run(LazyCallGraph::SCC &C) {
Chandler Carruth572e3402014-04-21 11:12:00 +000054 return PreservedAnalyses::all();
55 }
56 static StringRef name() { return "NoOpCGSCCPass"; }
57};
58
Chandler Carruth0b576b32015-01-06 02:50:06 +000059/// \brief No-op CGSCC analysis.
60struct NoOpCGSCCAnalysis {
61 struct Result {};
62 Result run(LazyCallGraph::SCC &) { return Result(); }
63 static StringRef name() { return "NoOpCGSCCAnalysis"; }
64 static void *ID() { return (void *)&PassID; }
65private:
66 static char PassID;
67};
68
69char NoOpCGSCCAnalysis::PassID;
70
Chandler Carruthd8330982014-01-12 09:34:22 +000071/// \brief No-op function pass which does nothing.
72struct NoOpFunctionPass {
Chandler Carruthd174ce42015-01-05 02:47:05 +000073 PreservedAnalyses run(Function &F) { return PreservedAnalyses::all(); }
Chandler Carruthd8330982014-01-12 09:34:22 +000074 static StringRef name() { return "NoOpFunctionPass"; }
75};
76
Chandler Carruth0b576b32015-01-06 02:50:06 +000077/// \brief No-op function analysis.
78struct NoOpFunctionAnalysis {
79 struct Result {};
80 Result run(Function &) { return Result(); }
81 static StringRef name() { return "NoOpFunctionAnalysis"; }
82 static void *ID() { return (void *)&PassID; }
83private:
84 static char PassID;
85};
86
87char NoOpFunctionAnalysis::PassID;
88
Chandler Carruth66445382014-01-11 08:16:35 +000089} // End anonymous namespace.
90
Chandler Carruthb70f6732015-01-06 02:21:37 +000091void llvm::registerModuleAnalyses(ModuleAnalysisManager &MAM) {
92#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
93 MAM.registerPass(CREATE_PASS);
94#include "PassRegistry.def"
95}
96
97void llvm::registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM) {
98#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
99 CGAM.registerPass(CREATE_PASS);
100#include "PassRegistry.def"
101}
102
103void llvm::registerFunctionAnalyses(FunctionAnalysisManager &FAM) {
104#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
105 FAM.registerPass(CREATE_PASS);
106#include "PassRegistry.def"
107}
108
Chandler Carruth9d2e58f2015-01-06 09:10:47 +0000109#ifndef NDEBUG
Chandler Carruth66445382014-01-11 08:16:35 +0000110static bool isModulePassName(StringRef Name) {
Chandler Carruth58944182014-04-21 08:08:50 +0000111#define MODULE_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
Chandler Carruth628503e2015-01-06 02:10:51 +0000112#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000113 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
Chandler Carruth628503e2015-01-06 02:10:51 +0000114 return true;
115#include "PassRegistry.def"
116
Chandler Carruth66445382014-01-11 08:16:35 +0000117 return false;
118}
Chandler Carruth9d2e58f2015-01-06 09:10:47 +0000119#endif
Chandler Carruth66445382014-01-11 08:16:35 +0000120
Chandler Carruth572e3402014-04-21 11:12:00 +0000121static bool isCGSCCPassName(StringRef Name) {
Chandler Carruth572e3402014-04-21 11:12:00 +0000122#define CGSCC_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
Chandler Carruth628503e2015-01-06 02:10:51 +0000123#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000124 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
Chandler Carruth628503e2015-01-06 02:10:51 +0000125 return true;
126#include "PassRegistry.def"
127
Chandler Carruth572e3402014-04-21 11:12:00 +0000128 return false;
129}
130
Chandler Carruthd8330982014-01-12 09:34:22 +0000131static bool isFunctionPassName(StringRef Name) {
Chandler Carruth58944182014-04-21 08:08:50 +0000132#define FUNCTION_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
Chandler Carruth628503e2015-01-06 02:10:51 +0000133#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000134 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
Chandler Carruth628503e2015-01-06 02:10:51 +0000135 return true;
136#include "PassRegistry.def"
137
Chandler Carruthd8330982014-01-12 09:34:22 +0000138 return false;
139}
140
Chandler Carruth66445382014-01-11 08:16:35 +0000141static bool parseModulePassName(ModulePassManager &MPM, StringRef Name) {
Chandler Carruth58944182014-04-21 08:08:50 +0000142#define MODULE_PASS(NAME, CREATE_PASS) \
143 if (Name == NAME) { \
144 MPM.addPass(CREATE_PASS); \
145 return true; \
Chandler Carruth52eef882014-01-12 12:15:39 +0000146 }
Chandler Carruth628503e2015-01-06 02:10:51 +0000147#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
148 if (Name == "require<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000149 MPM.addPass(RequireAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth628503e2015-01-06 02:10:51 +0000150 return true; \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000151 } \
152 if (Name == "invalidate<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000153 MPM.addPass(InvalidateAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000154 return true; \
Chandler Carruth628503e2015-01-06 02:10:51 +0000155 }
156#include "PassRegistry.def"
157
Chandler Carruth66445382014-01-11 08:16:35 +0000158 return false;
159}
160
Chandler Carruth572e3402014-04-21 11:12:00 +0000161static bool parseCGSCCPassName(CGSCCPassManager &CGPM, StringRef Name) {
Chandler Carruth572e3402014-04-21 11:12:00 +0000162#define CGSCC_PASS(NAME, CREATE_PASS) \
163 if (Name == NAME) { \
164 CGPM.addPass(CREATE_PASS); \
165 return true; \
166 }
Chandler Carruth628503e2015-01-06 02:10:51 +0000167#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
168 if (Name == "require<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000169 CGPM.addPass(RequireAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth628503e2015-01-06 02:10:51 +0000170 return true; \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000171 } \
172 if (Name == "invalidate<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000173 CGPM.addPass(InvalidateAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000174 return true; \
Chandler Carruth628503e2015-01-06 02:10:51 +0000175 }
176#include "PassRegistry.def"
177
Chandler Carruth572e3402014-04-21 11:12:00 +0000178 return false;
179}
180
Chandler Carruthd8330982014-01-12 09:34:22 +0000181static bool parseFunctionPassName(FunctionPassManager &FPM, StringRef Name) {
Chandler Carruth58944182014-04-21 08:08:50 +0000182#define FUNCTION_PASS(NAME, CREATE_PASS) \
183 if (Name == NAME) { \
184 FPM.addPass(CREATE_PASS); \
185 return true; \
Chandler Carruth52eef882014-01-12 12:15:39 +0000186 }
Chandler Carruth628503e2015-01-06 02:10:51 +0000187#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
188 if (Name == "require<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000189 FPM.addPass(RequireAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth628503e2015-01-06 02:10:51 +0000190 return true; \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000191 } \
192 if (Name == "invalidate<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000193 FPM.addPass(InvalidateAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000194 return true; \
Chandler Carruth628503e2015-01-06 02:10:51 +0000195 }
196#include "PassRegistry.def"
197
Chandler Carruthd8330982014-01-12 09:34:22 +0000198 return false;
199}
200
201static bool parseFunctionPassPipeline(FunctionPassManager &FPM,
Chandler Carruth4d356312014-01-20 11:34:08 +0000202 StringRef &PipelineText,
Chandler Carruth14a759e2015-01-13 22:42:38 +0000203 bool VerifyEachPass, bool DebugLogging) {
Chandler Carruthd8330982014-01-12 09:34:22 +0000204 for (;;) {
205 // Parse nested pass managers by recursing.
206 if (PipelineText.startswith("function(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000207 FunctionPassManager NestedFPM(DebugLogging);
Chandler Carruthd8330982014-01-12 09:34:22 +0000208
209 // Parse the inner pipeline inte the nested manager.
210 PipelineText = PipelineText.substr(strlen("function("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000211 if (!parseFunctionPassPipeline(NestedFPM, PipelineText, VerifyEachPass,
212 DebugLogging) ||
Chandler Carruth6546cb62014-01-12 10:02:02 +0000213 PipelineText.empty())
Chandler Carruthd8330982014-01-12 09:34:22 +0000214 return false;
Chandler Carruth6546cb62014-01-12 10:02:02 +0000215 assert(PipelineText[0] == ')');
Chandler Carruthd8330982014-01-12 09:34:22 +0000216 PipelineText = PipelineText.substr(1);
217
218 // Add the nested pass manager with the appropriate adaptor.
Chandler Carruthc3f3da32014-03-09 11:49:53 +0000219 FPM.addPass(std::move(NestedFPM));
Chandler Carruthd8330982014-01-12 09:34:22 +0000220 } else {
221 // Otherwise try to parse a pass name.
222 size_t End = PipelineText.find_first_of(",)");
223 if (!parseFunctionPassName(FPM, PipelineText.substr(0, End)))
224 return false;
Chandler Carruth4d356312014-01-20 11:34:08 +0000225 if (VerifyEachPass)
226 FPM.addPass(VerifierPass());
Chandler Carruthd8330982014-01-12 09:34:22 +0000227
228 PipelineText = PipelineText.substr(End);
229 }
230
231 if (PipelineText.empty() || PipelineText[0] == ')')
232 return true;
233
234 assert(PipelineText[0] == ',');
235 PipelineText = PipelineText.substr(1);
236 }
237}
238
Chandler Carruth572e3402014-04-21 11:12:00 +0000239static bool parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
Chandler Carruth14a759e2015-01-13 22:42:38 +0000240 StringRef &PipelineText, bool VerifyEachPass,
241 bool DebugLogging) {
Chandler Carruth572e3402014-04-21 11:12:00 +0000242 for (;;) {
243 // Parse nested pass managers by recursing.
244 if (PipelineText.startswith("cgscc(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000245 CGSCCPassManager NestedCGPM(DebugLogging);
Chandler Carruth572e3402014-04-21 11:12:00 +0000246
247 // Parse the inner pipeline into the nested manager.
248 PipelineText = PipelineText.substr(strlen("cgscc("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000249 if (!parseCGSCCPassPipeline(NestedCGPM, PipelineText, VerifyEachPass,
250 DebugLogging) ||
Chandler Carruth572e3402014-04-21 11:12:00 +0000251 PipelineText.empty())
252 return false;
253 assert(PipelineText[0] == ')');
254 PipelineText = PipelineText.substr(1);
255
256 // Add the nested pass manager with the appropriate adaptor.
257 CGPM.addPass(std::move(NestedCGPM));
258 } else if (PipelineText.startswith("function(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000259 FunctionPassManager NestedFPM(DebugLogging);
Chandler Carruth572e3402014-04-21 11:12:00 +0000260
261 // Parse the inner pipeline inte the nested manager.
262 PipelineText = PipelineText.substr(strlen("function("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000263 if (!parseFunctionPassPipeline(NestedFPM, PipelineText, VerifyEachPass,
264 DebugLogging) ||
Chandler Carruth572e3402014-04-21 11:12:00 +0000265 PipelineText.empty())
266 return false;
267 assert(PipelineText[0] == ')');
268 PipelineText = PipelineText.substr(1);
269
270 // Add the nested pass manager with the appropriate adaptor.
271 CGPM.addPass(createCGSCCToFunctionPassAdaptor(std::move(NestedFPM)));
272 } else {
273 // Otherwise try to parse a pass name.
274 size_t End = PipelineText.find_first_of(",)");
275 if (!parseCGSCCPassName(CGPM, PipelineText.substr(0, End)))
276 return false;
277 // FIXME: No verifier support for CGSCC passes!
278
279 PipelineText = PipelineText.substr(End);
280 }
281
282 if (PipelineText.empty() || PipelineText[0] == ')')
283 return true;
284
285 assert(PipelineText[0] == ',');
286 PipelineText = PipelineText.substr(1);
287 }
288}
289
Chandler Carruth66445382014-01-11 08:16:35 +0000290static bool parseModulePassPipeline(ModulePassManager &MPM,
Chandler Carruth4d356312014-01-20 11:34:08 +0000291 StringRef &PipelineText,
Chandler Carruth14a759e2015-01-13 22:42:38 +0000292 bool VerifyEachPass, bool DebugLogging) {
Chandler Carruth66445382014-01-11 08:16:35 +0000293 for (;;) {
294 // Parse nested pass managers by recursing.
295 if (PipelineText.startswith("module(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000296 ModulePassManager NestedMPM(DebugLogging);
Chandler Carruth258dbb32014-01-11 12:06:47 +0000297
298 // Parse the inner pipeline into the nested manager.
Chandler Carruth66445382014-01-11 08:16:35 +0000299 PipelineText = PipelineText.substr(strlen("module("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000300 if (!parseModulePassPipeline(NestedMPM, PipelineText, VerifyEachPass,
301 DebugLogging) ||
Chandler Carruth6546cb62014-01-12 10:02:02 +0000302 PipelineText.empty())
Chandler Carruth66445382014-01-11 08:16:35 +0000303 return false;
Chandler Carruth6546cb62014-01-12 10:02:02 +0000304 assert(PipelineText[0] == ')');
Chandler Carruth66445382014-01-11 08:16:35 +0000305 PipelineText = PipelineText.substr(1);
Chandler Carruth258dbb32014-01-11 12:06:47 +0000306
307 // Now add the nested manager as a module pass.
Chandler Carruthc3f3da32014-03-09 11:49:53 +0000308 MPM.addPass(std::move(NestedMPM));
Chandler Carruth572e3402014-04-21 11:12:00 +0000309 } else if (PipelineText.startswith("cgscc(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000310 CGSCCPassManager NestedCGPM(DebugLogging);
Chandler Carruth572e3402014-04-21 11:12:00 +0000311
312 // Parse the inner pipeline inte the nested manager.
313 PipelineText = PipelineText.substr(strlen("cgscc("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000314 if (!parseCGSCCPassPipeline(NestedCGPM, PipelineText, VerifyEachPass,
315 DebugLogging) ||
Chandler Carruth572e3402014-04-21 11:12:00 +0000316 PipelineText.empty())
317 return false;
318 assert(PipelineText[0] == ')');
319 PipelineText = PipelineText.substr(1);
320
321 // Add the nested pass manager with the appropriate adaptor.
322 MPM.addPass(
323 createModuleToPostOrderCGSCCPassAdaptor(std::move(NestedCGPM)));
Chandler Carruthd8330982014-01-12 09:34:22 +0000324 } else if (PipelineText.startswith("function(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000325 FunctionPassManager NestedFPM(DebugLogging);
Chandler Carruthd8330982014-01-12 09:34:22 +0000326
327 // Parse the inner pipeline inte the nested manager.
328 PipelineText = PipelineText.substr(strlen("function("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000329 if (!parseFunctionPassPipeline(NestedFPM, PipelineText, VerifyEachPass,
330 DebugLogging) ||
Chandler Carruth6546cb62014-01-12 10:02:02 +0000331 PipelineText.empty())
Chandler Carruthd8330982014-01-12 09:34:22 +0000332 return false;
Chandler Carruth6546cb62014-01-12 10:02:02 +0000333 assert(PipelineText[0] == ')');
Chandler Carruthd8330982014-01-12 09:34:22 +0000334 PipelineText = PipelineText.substr(1);
335
336 // Add the nested pass manager with the appropriate adaptor.
Chandler Carruthc3f3da32014-03-09 11:49:53 +0000337 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(NestedFPM)));
Chandler Carruth66445382014-01-11 08:16:35 +0000338 } else {
339 // Otherwise try to parse a pass name.
340 size_t End = PipelineText.find_first_of(",)");
341 if (!parseModulePassName(MPM, PipelineText.substr(0, End)))
342 return false;
Chandler Carruth4d356312014-01-20 11:34:08 +0000343 if (VerifyEachPass)
344 MPM.addPass(VerifierPass());
Chandler Carruth66445382014-01-11 08:16:35 +0000345
346 PipelineText = PipelineText.substr(End);
347 }
348
349 if (PipelineText.empty() || PipelineText[0] == ')')
350 return true;
351
352 assert(PipelineText[0] == ',');
353 PipelineText = PipelineText.substr(1);
354 }
355}
356
357// Primary pass pipeline description parsing routine.
358// FIXME: Should this routine accept a TargetMachine or require the caller to
359// pre-populate the analysis managers with target-specific stuff?
Chandler Carruth4d356312014-01-20 11:34:08 +0000360bool llvm::parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText,
Chandler Carruth14a759e2015-01-13 22:42:38 +0000361 bool VerifyEachPass, bool DebugLogging) {
Chandler Carruthea368f12015-01-06 08:37:58 +0000362 // By default, try to parse the pipeline as-if it were within an implicit
363 // 'module(...)' pass pipeline. If this will parse at all, it needs to
364 // consume the entire string.
Chandler Carruth14a759e2015-01-13 22:42:38 +0000365 if (parseModulePassPipeline(MPM, PipelineText, VerifyEachPass, DebugLogging))
Chandler Carruthea368f12015-01-06 08:37:58 +0000366 return PipelineText.empty();
Chandler Carruth66445382014-01-11 08:16:35 +0000367
Chandler Carruthea368f12015-01-06 08:37:58 +0000368 // This isn't parsable as a module pipeline, look for the end of a pass name
369 // and directly drop down to that layer.
Chandler Carruth6546cb62014-01-12 10:02:02 +0000370 StringRef FirstName =
371 PipelineText.substr(0, PipelineText.find_first_of(",)"));
Chandler Carruthea368f12015-01-06 08:37:58 +0000372 assert(!isModulePassName(FirstName) &&
373 "Already handled all module pipeline options.");
Chandler Carruth66445382014-01-11 08:16:35 +0000374
Chandler Carruthea368f12015-01-06 08:37:58 +0000375 // If this looks like a CGSCC pass, parse the whole thing as a CGSCC
376 // pipeline.
Chandler Carruth572e3402014-04-21 11:12:00 +0000377 if (isCGSCCPassName(FirstName)) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000378 CGSCCPassManager CGPM(DebugLogging);
379 if (!parseCGSCCPassPipeline(CGPM, PipelineText, VerifyEachPass,
380 DebugLogging) ||
Chandler Carruth572e3402014-04-21 11:12:00 +0000381 !PipelineText.empty())
382 return false;
383 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
384 return true;
385 }
386
Chandler Carruthea368f12015-01-06 08:37:58 +0000387 // Similarly, if this looks like a Function pass, parse the whole thing as
388 // a Function pipelien.
Chandler Carruthd8330982014-01-12 09:34:22 +0000389 if (isFunctionPassName(FirstName)) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000390 FunctionPassManager FPM(DebugLogging);
391 if (!parseFunctionPassPipeline(FPM, PipelineText, VerifyEachPass,
392 DebugLogging) ||
Chandler Carruth4d356312014-01-20 11:34:08 +0000393 !PipelineText.empty())
Chandler Carruthd8330982014-01-12 09:34:22 +0000394 return false;
Chandler Carruthc3f3da32014-03-09 11:49:53 +0000395 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
Chandler Carruthd8330982014-01-12 09:34:22 +0000396 return true;
397 }
Chandler Carruth66445382014-01-11 08:16:35 +0000398
399 return false;
400}