blob: 1788e695d5e1e9a0d8d69f7ec316c26923ce5645 [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 Carruth83ba2692015-01-24 04:19:17 +000028#include "llvm/Transforms/InstCombine/InstCombine.h"
Chandler Carruth66445382014-01-11 08:16:35 +000029
30using namespace llvm;
31
32namespace {
33
Chandler Carruthd8330982014-01-12 09:34:22 +000034/// \brief No-op module pass which does nothing.
Chandler Carruth66445382014-01-11 08:16:35 +000035struct NoOpModulePass {
Chandler Carruthd174ce42015-01-05 02:47:05 +000036 PreservedAnalyses run(Module &M) { return PreservedAnalyses::all(); }
Chandler Carrutha13f27c2014-01-11 11:52:05 +000037 static StringRef name() { return "NoOpModulePass"; }
Chandler Carruth66445382014-01-11 08:16:35 +000038};
39
Chandler Carruth0b576b32015-01-06 02:50:06 +000040/// \brief No-op module analysis.
41struct NoOpModuleAnalysis {
42 struct Result {};
43 Result run(Module &) { return Result(); }
44 static StringRef name() { return "NoOpModuleAnalysis"; }
45 static void *ID() { return (void *)&PassID; }
46private:
47 static char PassID;
48};
49
50char NoOpModuleAnalysis::PassID;
51
Chandler Carruth572e3402014-04-21 11:12:00 +000052/// \brief No-op CGSCC pass which does nothing.
53struct NoOpCGSCCPass {
Chandler Carruthd174ce42015-01-05 02:47:05 +000054 PreservedAnalyses run(LazyCallGraph::SCC &C) {
Chandler Carruth572e3402014-04-21 11:12:00 +000055 return PreservedAnalyses::all();
56 }
57 static StringRef name() { return "NoOpCGSCCPass"; }
58};
59
Chandler Carruth0b576b32015-01-06 02:50:06 +000060/// \brief No-op CGSCC analysis.
61struct NoOpCGSCCAnalysis {
62 struct Result {};
63 Result run(LazyCallGraph::SCC &) { return Result(); }
64 static StringRef name() { return "NoOpCGSCCAnalysis"; }
65 static void *ID() { return (void *)&PassID; }
66private:
67 static char PassID;
68};
69
70char NoOpCGSCCAnalysis::PassID;
71
Chandler Carruthd8330982014-01-12 09:34:22 +000072/// \brief No-op function pass which does nothing.
73struct NoOpFunctionPass {
Chandler Carruthd174ce42015-01-05 02:47:05 +000074 PreservedAnalyses run(Function &F) { return PreservedAnalyses::all(); }
Chandler Carruthd8330982014-01-12 09:34:22 +000075 static StringRef name() { return "NoOpFunctionPass"; }
76};
77
Chandler Carruth0b576b32015-01-06 02:50:06 +000078/// \brief No-op function analysis.
79struct NoOpFunctionAnalysis {
80 struct Result {};
81 Result run(Function &) { return Result(); }
82 static StringRef name() { return "NoOpFunctionAnalysis"; }
83 static void *ID() { return (void *)&PassID; }
84private:
85 static char PassID;
86};
87
88char NoOpFunctionAnalysis::PassID;
89
Chandler Carruth66445382014-01-11 08:16:35 +000090} // End anonymous namespace.
91
Chandler Carruthb70f6732015-01-06 02:21:37 +000092void llvm::registerModuleAnalyses(ModuleAnalysisManager &MAM) {
93#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
94 MAM.registerPass(CREATE_PASS);
95#include "PassRegistry.def"
96}
97
98void llvm::registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM) {
99#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
100 CGAM.registerPass(CREATE_PASS);
101#include "PassRegistry.def"
102}
103
104void llvm::registerFunctionAnalyses(FunctionAnalysisManager &FAM) {
105#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
106 FAM.registerPass(CREATE_PASS);
107#include "PassRegistry.def"
108}
109
Chandler Carruth9d2e58f2015-01-06 09:10:47 +0000110#ifndef NDEBUG
Chandler Carruth66445382014-01-11 08:16:35 +0000111static bool isModulePassName(StringRef Name) {
Chandler Carruth58944182014-04-21 08:08:50 +0000112#define MODULE_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
Chandler Carruth628503e2015-01-06 02:10:51 +0000113#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000114 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
Chandler Carruth628503e2015-01-06 02:10:51 +0000115 return true;
116#include "PassRegistry.def"
117
Chandler Carruth66445382014-01-11 08:16:35 +0000118 return false;
119}
Chandler Carruth9d2e58f2015-01-06 09:10:47 +0000120#endif
Chandler Carruth66445382014-01-11 08:16:35 +0000121
Chandler Carruth572e3402014-04-21 11:12:00 +0000122static bool isCGSCCPassName(StringRef Name) {
Chandler Carruth572e3402014-04-21 11:12:00 +0000123#define CGSCC_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
Chandler Carruth628503e2015-01-06 02:10:51 +0000124#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000125 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
Chandler Carruth628503e2015-01-06 02:10:51 +0000126 return true;
127#include "PassRegistry.def"
128
Chandler Carruth572e3402014-04-21 11:12:00 +0000129 return false;
130}
131
Chandler Carruthd8330982014-01-12 09:34:22 +0000132static bool isFunctionPassName(StringRef Name) {
Chandler Carruth58944182014-04-21 08:08:50 +0000133#define FUNCTION_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
Chandler Carruth628503e2015-01-06 02:10:51 +0000134#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000135 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
Chandler Carruth628503e2015-01-06 02:10:51 +0000136 return true;
137#include "PassRegistry.def"
138
Chandler Carruthd8330982014-01-12 09:34:22 +0000139 return false;
140}
141
Chandler Carruth66445382014-01-11 08:16:35 +0000142static bool parseModulePassName(ModulePassManager &MPM, StringRef Name) {
Chandler Carruth58944182014-04-21 08:08:50 +0000143#define MODULE_PASS(NAME, CREATE_PASS) \
144 if (Name == NAME) { \
145 MPM.addPass(CREATE_PASS); \
146 return true; \
Chandler Carruth52eef882014-01-12 12:15:39 +0000147 }
Chandler Carruth628503e2015-01-06 02:10:51 +0000148#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
149 if (Name == "require<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000150 MPM.addPass(RequireAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth628503e2015-01-06 02:10:51 +0000151 return true; \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000152 } \
153 if (Name == "invalidate<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000154 MPM.addPass(InvalidateAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000155 return true; \
Chandler Carruth628503e2015-01-06 02:10:51 +0000156 }
157#include "PassRegistry.def"
158
Chandler Carruth66445382014-01-11 08:16:35 +0000159 return false;
160}
161
Chandler Carruth572e3402014-04-21 11:12:00 +0000162static bool parseCGSCCPassName(CGSCCPassManager &CGPM, StringRef Name) {
Chandler Carruth572e3402014-04-21 11:12:00 +0000163#define CGSCC_PASS(NAME, CREATE_PASS) \
164 if (Name == NAME) { \
165 CGPM.addPass(CREATE_PASS); \
166 return true; \
167 }
Chandler Carruth628503e2015-01-06 02:10:51 +0000168#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
169 if (Name == "require<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000170 CGPM.addPass(RequireAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth628503e2015-01-06 02:10:51 +0000171 return true; \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000172 } \
173 if (Name == "invalidate<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000174 CGPM.addPass(InvalidateAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000175 return true; \
Chandler Carruth628503e2015-01-06 02:10:51 +0000176 }
177#include "PassRegistry.def"
178
Chandler Carruth572e3402014-04-21 11:12:00 +0000179 return false;
180}
181
Chandler Carruthd8330982014-01-12 09:34:22 +0000182static bool parseFunctionPassName(FunctionPassManager &FPM, StringRef Name) {
Chandler Carruth58944182014-04-21 08:08:50 +0000183#define FUNCTION_PASS(NAME, CREATE_PASS) \
184 if (Name == NAME) { \
185 FPM.addPass(CREATE_PASS); \
186 return true; \
Chandler Carruth52eef882014-01-12 12:15:39 +0000187 }
Chandler Carruth628503e2015-01-06 02:10:51 +0000188#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
189 if (Name == "require<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000190 FPM.addPass(RequireAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth628503e2015-01-06 02:10:51 +0000191 return true; \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000192 } \
193 if (Name == "invalidate<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000194 FPM.addPass(InvalidateAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000195 return true; \
Chandler Carruth628503e2015-01-06 02:10:51 +0000196 }
197#include "PassRegistry.def"
198
Chandler Carruthd8330982014-01-12 09:34:22 +0000199 return false;
200}
201
202static bool parseFunctionPassPipeline(FunctionPassManager &FPM,
Chandler Carruth4d356312014-01-20 11:34:08 +0000203 StringRef &PipelineText,
Chandler Carruth14a759e2015-01-13 22:42:38 +0000204 bool VerifyEachPass, bool DebugLogging) {
Chandler Carruthd8330982014-01-12 09:34:22 +0000205 for (;;) {
206 // Parse nested pass managers by recursing.
207 if (PipelineText.startswith("function(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000208 FunctionPassManager NestedFPM(DebugLogging);
Chandler Carruthd8330982014-01-12 09:34:22 +0000209
210 // Parse the inner pipeline inte the nested manager.
211 PipelineText = PipelineText.substr(strlen("function("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000212 if (!parseFunctionPassPipeline(NestedFPM, PipelineText, VerifyEachPass,
213 DebugLogging) ||
Chandler Carruth6546cb62014-01-12 10:02:02 +0000214 PipelineText.empty())
Chandler Carruthd8330982014-01-12 09:34:22 +0000215 return false;
Chandler Carruth6546cb62014-01-12 10:02:02 +0000216 assert(PipelineText[0] == ')');
Chandler Carruthd8330982014-01-12 09:34:22 +0000217 PipelineText = PipelineText.substr(1);
218
219 // Add the nested pass manager with the appropriate adaptor.
Chandler Carruthc3f3da32014-03-09 11:49:53 +0000220 FPM.addPass(std::move(NestedFPM));
Chandler Carruthd8330982014-01-12 09:34:22 +0000221 } else {
222 // Otherwise try to parse a pass name.
223 size_t End = PipelineText.find_first_of(",)");
224 if (!parseFunctionPassName(FPM, PipelineText.substr(0, End)))
225 return false;
Chandler Carruth4d356312014-01-20 11:34:08 +0000226 if (VerifyEachPass)
227 FPM.addPass(VerifierPass());
Chandler Carruthd8330982014-01-12 09:34:22 +0000228
229 PipelineText = PipelineText.substr(End);
230 }
231
232 if (PipelineText.empty() || PipelineText[0] == ')')
233 return true;
234
235 assert(PipelineText[0] == ',');
236 PipelineText = PipelineText.substr(1);
237 }
238}
239
Chandler Carruth572e3402014-04-21 11:12:00 +0000240static bool parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
Chandler Carruth14a759e2015-01-13 22:42:38 +0000241 StringRef &PipelineText, bool VerifyEachPass,
242 bool DebugLogging) {
Chandler Carruth572e3402014-04-21 11:12:00 +0000243 for (;;) {
244 // Parse nested pass managers by recursing.
245 if (PipelineText.startswith("cgscc(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000246 CGSCCPassManager NestedCGPM(DebugLogging);
Chandler Carruth572e3402014-04-21 11:12:00 +0000247
248 // Parse the inner pipeline into the nested manager.
249 PipelineText = PipelineText.substr(strlen("cgscc("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000250 if (!parseCGSCCPassPipeline(NestedCGPM, PipelineText, VerifyEachPass,
251 DebugLogging) ||
Chandler Carruth572e3402014-04-21 11:12:00 +0000252 PipelineText.empty())
253 return false;
254 assert(PipelineText[0] == ')');
255 PipelineText = PipelineText.substr(1);
256
257 // Add the nested pass manager with the appropriate adaptor.
258 CGPM.addPass(std::move(NestedCGPM));
259 } else if (PipelineText.startswith("function(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000260 FunctionPassManager NestedFPM(DebugLogging);
Chandler Carruth572e3402014-04-21 11:12:00 +0000261
262 // Parse the inner pipeline inte the nested manager.
263 PipelineText = PipelineText.substr(strlen("function("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000264 if (!parseFunctionPassPipeline(NestedFPM, PipelineText, VerifyEachPass,
265 DebugLogging) ||
Chandler Carruth572e3402014-04-21 11:12:00 +0000266 PipelineText.empty())
267 return false;
268 assert(PipelineText[0] == ')');
269 PipelineText = PipelineText.substr(1);
270
271 // Add the nested pass manager with the appropriate adaptor.
272 CGPM.addPass(createCGSCCToFunctionPassAdaptor(std::move(NestedFPM)));
273 } else {
274 // Otherwise try to parse a pass name.
275 size_t End = PipelineText.find_first_of(",)");
276 if (!parseCGSCCPassName(CGPM, PipelineText.substr(0, End)))
277 return false;
278 // FIXME: No verifier support for CGSCC passes!
279
280 PipelineText = PipelineText.substr(End);
281 }
282
283 if (PipelineText.empty() || PipelineText[0] == ')')
284 return true;
285
286 assert(PipelineText[0] == ',');
287 PipelineText = PipelineText.substr(1);
288 }
289}
290
Chandler Carruth66445382014-01-11 08:16:35 +0000291static bool parseModulePassPipeline(ModulePassManager &MPM,
Chandler Carruth4d356312014-01-20 11:34:08 +0000292 StringRef &PipelineText,
Chandler Carruth14a759e2015-01-13 22:42:38 +0000293 bool VerifyEachPass, bool DebugLogging) {
Chandler Carruth66445382014-01-11 08:16:35 +0000294 for (;;) {
295 // Parse nested pass managers by recursing.
296 if (PipelineText.startswith("module(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000297 ModulePassManager NestedMPM(DebugLogging);
Chandler Carruth258dbb32014-01-11 12:06:47 +0000298
299 // Parse the inner pipeline into the nested manager.
Chandler Carruth66445382014-01-11 08:16:35 +0000300 PipelineText = PipelineText.substr(strlen("module("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000301 if (!parseModulePassPipeline(NestedMPM, PipelineText, VerifyEachPass,
302 DebugLogging) ||
Chandler Carruth6546cb62014-01-12 10:02:02 +0000303 PipelineText.empty())
Chandler Carruth66445382014-01-11 08:16:35 +0000304 return false;
Chandler Carruth6546cb62014-01-12 10:02:02 +0000305 assert(PipelineText[0] == ')');
Chandler Carruth66445382014-01-11 08:16:35 +0000306 PipelineText = PipelineText.substr(1);
Chandler Carruth258dbb32014-01-11 12:06:47 +0000307
308 // Now add the nested manager as a module pass.
Chandler Carruthc3f3da32014-03-09 11:49:53 +0000309 MPM.addPass(std::move(NestedMPM));
Chandler Carruth572e3402014-04-21 11:12:00 +0000310 } else if (PipelineText.startswith("cgscc(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000311 CGSCCPassManager NestedCGPM(DebugLogging);
Chandler Carruth572e3402014-04-21 11:12:00 +0000312
313 // Parse the inner pipeline inte the nested manager.
314 PipelineText = PipelineText.substr(strlen("cgscc("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000315 if (!parseCGSCCPassPipeline(NestedCGPM, PipelineText, VerifyEachPass,
316 DebugLogging) ||
Chandler Carruth572e3402014-04-21 11:12:00 +0000317 PipelineText.empty())
318 return false;
319 assert(PipelineText[0] == ')');
320 PipelineText = PipelineText.substr(1);
321
322 // Add the nested pass manager with the appropriate adaptor.
323 MPM.addPass(
324 createModuleToPostOrderCGSCCPassAdaptor(std::move(NestedCGPM)));
Chandler Carruthd8330982014-01-12 09:34:22 +0000325 } else if (PipelineText.startswith("function(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000326 FunctionPassManager NestedFPM(DebugLogging);
Chandler Carruthd8330982014-01-12 09:34:22 +0000327
328 // Parse the inner pipeline inte the nested manager.
329 PipelineText = PipelineText.substr(strlen("function("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000330 if (!parseFunctionPassPipeline(NestedFPM, PipelineText, VerifyEachPass,
331 DebugLogging) ||
Chandler Carruth6546cb62014-01-12 10:02:02 +0000332 PipelineText.empty())
Chandler Carruthd8330982014-01-12 09:34:22 +0000333 return false;
Chandler Carruth6546cb62014-01-12 10:02:02 +0000334 assert(PipelineText[0] == ')');
Chandler Carruthd8330982014-01-12 09:34:22 +0000335 PipelineText = PipelineText.substr(1);
336
337 // Add the nested pass manager with the appropriate adaptor.
Chandler Carruthc3f3da32014-03-09 11:49:53 +0000338 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(NestedFPM)));
Chandler Carruth66445382014-01-11 08:16:35 +0000339 } else {
340 // Otherwise try to parse a pass name.
341 size_t End = PipelineText.find_first_of(",)");
342 if (!parseModulePassName(MPM, PipelineText.substr(0, End)))
343 return false;
Chandler Carruth4d356312014-01-20 11:34:08 +0000344 if (VerifyEachPass)
345 MPM.addPass(VerifierPass());
Chandler Carruth66445382014-01-11 08:16:35 +0000346
347 PipelineText = PipelineText.substr(End);
348 }
349
350 if (PipelineText.empty() || PipelineText[0] == ')')
351 return true;
352
353 assert(PipelineText[0] == ',');
354 PipelineText = PipelineText.substr(1);
355 }
356}
357
358// Primary pass pipeline description parsing routine.
359// FIXME: Should this routine accept a TargetMachine or require the caller to
360// pre-populate the analysis managers with target-specific stuff?
Chandler Carruth4d356312014-01-20 11:34:08 +0000361bool llvm::parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText,
Chandler Carruth14a759e2015-01-13 22:42:38 +0000362 bool VerifyEachPass, bool DebugLogging) {
Chandler Carruthea368f12015-01-06 08:37:58 +0000363 // By default, try to parse the pipeline as-if it were within an implicit
364 // 'module(...)' pass pipeline. If this will parse at all, it needs to
365 // consume the entire string.
Chandler Carruth14a759e2015-01-13 22:42:38 +0000366 if (parseModulePassPipeline(MPM, PipelineText, VerifyEachPass, DebugLogging))
Chandler Carruthea368f12015-01-06 08:37:58 +0000367 return PipelineText.empty();
Chandler Carruth66445382014-01-11 08:16:35 +0000368
Chandler Carruthea368f12015-01-06 08:37:58 +0000369 // This isn't parsable as a module pipeline, look for the end of a pass name
370 // and directly drop down to that layer.
Chandler Carruth6546cb62014-01-12 10:02:02 +0000371 StringRef FirstName =
372 PipelineText.substr(0, PipelineText.find_first_of(",)"));
Chandler Carruthea368f12015-01-06 08:37:58 +0000373 assert(!isModulePassName(FirstName) &&
374 "Already handled all module pipeline options.");
Chandler Carruth66445382014-01-11 08:16:35 +0000375
Chandler Carruthea368f12015-01-06 08:37:58 +0000376 // If this looks like a CGSCC pass, parse the whole thing as a CGSCC
377 // pipeline.
Chandler Carruth572e3402014-04-21 11:12:00 +0000378 if (isCGSCCPassName(FirstName)) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000379 CGSCCPassManager CGPM(DebugLogging);
380 if (!parseCGSCCPassPipeline(CGPM, PipelineText, VerifyEachPass,
381 DebugLogging) ||
Chandler Carruth572e3402014-04-21 11:12:00 +0000382 !PipelineText.empty())
383 return false;
384 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
385 return true;
386 }
387
Chandler Carruthea368f12015-01-06 08:37:58 +0000388 // Similarly, if this looks like a Function pass, parse the whole thing as
389 // a Function pipelien.
Chandler Carruthd8330982014-01-12 09:34:22 +0000390 if (isFunctionPassName(FirstName)) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000391 FunctionPassManager FPM(DebugLogging);
392 if (!parseFunctionPassPipeline(FPM, PipelineText, VerifyEachPass,
393 DebugLogging) ||
Chandler Carruth4d356312014-01-20 11:34:08 +0000394 !PipelineText.empty())
Chandler Carruthd8330982014-01-12 09:34:22 +0000395 return false;
Chandler Carruthc3f3da32014-03-09 11:49:53 +0000396 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
Chandler Carruthd8330982014-01-12 09:34:22 +0000397 return true;
398 }
Chandler Carruth66445382014-01-11 08:16:35 +0000399
400 return false;
401}