blob: 149432ed3c5db2bd194cf0047c3af36e5efeb963 [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 Carruth43e590e2015-01-24 11:13:02 +000029#include "llvm/Transforms/Scalar/LowerExpectIntrinsic.h"
Chandler Carruth66445382014-01-11 08:16:35 +000030
31using namespace llvm;
32
33namespace {
34
Chandler Carruthd8330982014-01-12 09:34:22 +000035/// \brief No-op module pass which does nothing.
Chandler Carruth66445382014-01-11 08:16:35 +000036struct NoOpModulePass {
Chandler Carruthd174ce42015-01-05 02:47:05 +000037 PreservedAnalyses run(Module &M) { return PreservedAnalyses::all(); }
Chandler Carrutha13f27c2014-01-11 11:52:05 +000038 static StringRef name() { return "NoOpModulePass"; }
Chandler Carruth66445382014-01-11 08:16:35 +000039};
40
Chandler Carruth0b576b32015-01-06 02:50:06 +000041/// \brief No-op module analysis.
42struct NoOpModuleAnalysis {
43 struct Result {};
44 Result run(Module &) { return Result(); }
45 static StringRef name() { return "NoOpModuleAnalysis"; }
46 static void *ID() { return (void *)&PassID; }
47private:
48 static char PassID;
49};
50
51char NoOpModuleAnalysis::PassID;
52
Chandler Carruth572e3402014-04-21 11:12:00 +000053/// \brief No-op CGSCC pass which does nothing.
54struct NoOpCGSCCPass {
Chandler Carruthd174ce42015-01-05 02:47:05 +000055 PreservedAnalyses run(LazyCallGraph::SCC &C) {
Chandler Carruth572e3402014-04-21 11:12:00 +000056 return PreservedAnalyses::all();
57 }
58 static StringRef name() { return "NoOpCGSCCPass"; }
59};
60
Chandler Carruth0b576b32015-01-06 02:50:06 +000061/// \brief No-op CGSCC analysis.
62struct NoOpCGSCCAnalysis {
63 struct Result {};
64 Result run(LazyCallGraph::SCC &) { return Result(); }
65 static StringRef name() { return "NoOpCGSCCAnalysis"; }
66 static void *ID() { return (void *)&PassID; }
67private:
68 static char PassID;
69};
70
71char NoOpCGSCCAnalysis::PassID;
72
Chandler Carruthd8330982014-01-12 09:34:22 +000073/// \brief No-op function pass which does nothing.
74struct NoOpFunctionPass {
Chandler Carruthd174ce42015-01-05 02:47:05 +000075 PreservedAnalyses run(Function &F) { return PreservedAnalyses::all(); }
Chandler Carruthd8330982014-01-12 09:34:22 +000076 static StringRef name() { return "NoOpFunctionPass"; }
77};
78
Chandler Carruth0b576b32015-01-06 02:50:06 +000079/// \brief No-op function analysis.
80struct NoOpFunctionAnalysis {
81 struct Result {};
82 Result run(Function &) { return Result(); }
83 static StringRef name() { return "NoOpFunctionAnalysis"; }
84 static void *ID() { return (void *)&PassID; }
85private:
86 static char PassID;
87};
88
89char NoOpFunctionAnalysis::PassID;
90
Chandler Carruth66445382014-01-11 08:16:35 +000091} // End anonymous namespace.
92
Chandler Carruthb70f6732015-01-06 02:21:37 +000093void llvm::registerModuleAnalyses(ModuleAnalysisManager &MAM) {
94#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
95 MAM.registerPass(CREATE_PASS);
96#include "PassRegistry.def"
97}
98
99void llvm::registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM) {
100#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
101 CGAM.registerPass(CREATE_PASS);
102#include "PassRegistry.def"
103}
104
105void llvm::registerFunctionAnalyses(FunctionAnalysisManager &FAM) {
106#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
107 FAM.registerPass(CREATE_PASS);
108#include "PassRegistry.def"
109}
110
Chandler Carruth9d2e58f2015-01-06 09:10:47 +0000111#ifndef NDEBUG
Chandler Carruth66445382014-01-11 08:16:35 +0000112static bool isModulePassName(StringRef Name) {
Chandler Carruth58944182014-04-21 08:08:50 +0000113#define MODULE_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
Chandler Carruth628503e2015-01-06 02:10:51 +0000114#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000115 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
Chandler Carruth628503e2015-01-06 02:10:51 +0000116 return true;
117#include "PassRegistry.def"
118
Chandler Carruth66445382014-01-11 08:16:35 +0000119 return false;
120}
Chandler Carruth9d2e58f2015-01-06 09:10:47 +0000121#endif
Chandler Carruth66445382014-01-11 08:16:35 +0000122
Chandler Carruth572e3402014-04-21 11:12:00 +0000123static bool isCGSCCPassName(StringRef Name) {
Chandler Carruth572e3402014-04-21 11:12:00 +0000124#define CGSCC_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
Chandler Carruth628503e2015-01-06 02:10:51 +0000125#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000126 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
Chandler Carruth628503e2015-01-06 02:10:51 +0000127 return true;
128#include "PassRegistry.def"
129
Chandler Carruth572e3402014-04-21 11:12:00 +0000130 return false;
131}
132
Chandler Carruthd8330982014-01-12 09:34:22 +0000133static bool isFunctionPassName(StringRef Name) {
Chandler Carruth58944182014-04-21 08:08:50 +0000134#define FUNCTION_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
Chandler Carruth628503e2015-01-06 02:10:51 +0000135#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000136 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
Chandler Carruth628503e2015-01-06 02:10:51 +0000137 return true;
138#include "PassRegistry.def"
139
Chandler Carruthd8330982014-01-12 09:34:22 +0000140 return false;
141}
142
Chandler Carruth66445382014-01-11 08:16:35 +0000143static bool parseModulePassName(ModulePassManager &MPM, StringRef Name) {
Chandler Carruth58944182014-04-21 08:08:50 +0000144#define MODULE_PASS(NAME, CREATE_PASS) \
145 if (Name == NAME) { \
146 MPM.addPass(CREATE_PASS); \
147 return true; \
Chandler Carruth52eef882014-01-12 12:15:39 +0000148 }
Chandler Carruth628503e2015-01-06 02:10:51 +0000149#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
150 if (Name == "require<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000151 MPM.addPass(RequireAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth628503e2015-01-06 02:10:51 +0000152 return true; \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000153 } \
154 if (Name == "invalidate<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000155 MPM.addPass(InvalidateAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000156 return true; \
Chandler Carruth628503e2015-01-06 02:10:51 +0000157 }
158#include "PassRegistry.def"
159
Chandler Carruth66445382014-01-11 08:16:35 +0000160 return false;
161}
162
Chandler Carruth572e3402014-04-21 11:12:00 +0000163static bool parseCGSCCPassName(CGSCCPassManager &CGPM, StringRef Name) {
Chandler Carruth572e3402014-04-21 11:12:00 +0000164#define CGSCC_PASS(NAME, CREATE_PASS) \
165 if (Name == NAME) { \
166 CGPM.addPass(CREATE_PASS); \
167 return true; \
168 }
Chandler Carruth628503e2015-01-06 02:10:51 +0000169#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
170 if (Name == "require<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000171 CGPM.addPass(RequireAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth628503e2015-01-06 02:10:51 +0000172 return true; \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000173 } \
174 if (Name == "invalidate<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000175 CGPM.addPass(InvalidateAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000176 return true; \
Chandler Carruth628503e2015-01-06 02:10:51 +0000177 }
178#include "PassRegistry.def"
179
Chandler Carruth572e3402014-04-21 11:12:00 +0000180 return false;
181}
182
Chandler Carruthd8330982014-01-12 09:34:22 +0000183static bool parseFunctionPassName(FunctionPassManager &FPM, StringRef Name) {
Chandler Carruth58944182014-04-21 08:08:50 +0000184#define FUNCTION_PASS(NAME, CREATE_PASS) \
185 if (Name == NAME) { \
186 FPM.addPass(CREATE_PASS); \
187 return true; \
Chandler Carruth52eef882014-01-12 12:15:39 +0000188 }
Chandler Carruth628503e2015-01-06 02:10:51 +0000189#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
190 if (Name == "require<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000191 FPM.addPass(RequireAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth628503e2015-01-06 02:10:51 +0000192 return true; \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000193 } \
194 if (Name == "invalidate<" NAME ">") { \
Chandler Carruthe5b0a9c2015-01-07 11:14:51 +0000195 FPM.addPass(InvalidateAnalysisPass<decltype(CREATE_PASS)>()); \
Chandler Carruth3472ffb2015-01-06 04:49:44 +0000196 return true; \
Chandler Carruth628503e2015-01-06 02:10:51 +0000197 }
198#include "PassRegistry.def"
199
Chandler Carruthd8330982014-01-12 09:34:22 +0000200 return false;
201}
202
203static bool parseFunctionPassPipeline(FunctionPassManager &FPM,
Chandler Carruth4d356312014-01-20 11:34:08 +0000204 StringRef &PipelineText,
Chandler Carruth14a759e2015-01-13 22:42:38 +0000205 bool VerifyEachPass, bool DebugLogging) {
Chandler Carruthd8330982014-01-12 09:34:22 +0000206 for (;;) {
207 // Parse nested pass managers by recursing.
208 if (PipelineText.startswith("function(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000209 FunctionPassManager NestedFPM(DebugLogging);
Chandler Carruthd8330982014-01-12 09:34:22 +0000210
211 // Parse the inner pipeline inte the nested manager.
212 PipelineText = PipelineText.substr(strlen("function("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000213 if (!parseFunctionPassPipeline(NestedFPM, PipelineText, VerifyEachPass,
214 DebugLogging) ||
Chandler Carruth6546cb62014-01-12 10:02:02 +0000215 PipelineText.empty())
Chandler Carruthd8330982014-01-12 09:34:22 +0000216 return false;
Chandler Carruth6546cb62014-01-12 10:02:02 +0000217 assert(PipelineText[0] == ')');
Chandler Carruthd8330982014-01-12 09:34:22 +0000218 PipelineText = PipelineText.substr(1);
219
220 // Add the nested pass manager with the appropriate adaptor.
Chandler Carruthc3f3da32014-03-09 11:49:53 +0000221 FPM.addPass(std::move(NestedFPM));
Chandler Carruthd8330982014-01-12 09:34:22 +0000222 } else {
223 // Otherwise try to parse a pass name.
224 size_t End = PipelineText.find_first_of(",)");
225 if (!parseFunctionPassName(FPM, PipelineText.substr(0, End)))
226 return false;
Chandler Carruth4d356312014-01-20 11:34:08 +0000227 if (VerifyEachPass)
228 FPM.addPass(VerifierPass());
Chandler Carruthd8330982014-01-12 09:34:22 +0000229
230 PipelineText = PipelineText.substr(End);
231 }
232
233 if (PipelineText.empty() || PipelineText[0] == ')')
234 return true;
235
236 assert(PipelineText[0] == ',');
237 PipelineText = PipelineText.substr(1);
238 }
239}
240
Chandler Carruth572e3402014-04-21 11:12:00 +0000241static bool parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
Chandler Carruth14a759e2015-01-13 22:42:38 +0000242 StringRef &PipelineText, bool VerifyEachPass,
243 bool DebugLogging) {
Chandler Carruth572e3402014-04-21 11:12:00 +0000244 for (;;) {
245 // Parse nested pass managers by recursing.
246 if (PipelineText.startswith("cgscc(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000247 CGSCCPassManager NestedCGPM(DebugLogging);
Chandler Carruth572e3402014-04-21 11:12:00 +0000248
249 // Parse the inner pipeline into the nested manager.
250 PipelineText = PipelineText.substr(strlen("cgscc("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000251 if (!parseCGSCCPassPipeline(NestedCGPM, PipelineText, VerifyEachPass,
252 DebugLogging) ||
Chandler Carruth572e3402014-04-21 11:12:00 +0000253 PipelineText.empty())
254 return false;
255 assert(PipelineText[0] == ')');
256 PipelineText = PipelineText.substr(1);
257
258 // Add the nested pass manager with the appropriate adaptor.
259 CGPM.addPass(std::move(NestedCGPM));
260 } else if (PipelineText.startswith("function(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000261 FunctionPassManager NestedFPM(DebugLogging);
Chandler Carruth572e3402014-04-21 11:12:00 +0000262
263 // Parse the inner pipeline inte the nested manager.
264 PipelineText = PipelineText.substr(strlen("function("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000265 if (!parseFunctionPassPipeline(NestedFPM, PipelineText, VerifyEachPass,
266 DebugLogging) ||
Chandler Carruth572e3402014-04-21 11:12:00 +0000267 PipelineText.empty())
268 return false;
269 assert(PipelineText[0] == ')');
270 PipelineText = PipelineText.substr(1);
271
272 // Add the nested pass manager with the appropriate adaptor.
273 CGPM.addPass(createCGSCCToFunctionPassAdaptor(std::move(NestedFPM)));
274 } else {
275 // Otherwise try to parse a pass name.
276 size_t End = PipelineText.find_first_of(",)");
277 if (!parseCGSCCPassName(CGPM, PipelineText.substr(0, End)))
278 return false;
279 // FIXME: No verifier support for CGSCC passes!
280
281 PipelineText = PipelineText.substr(End);
282 }
283
284 if (PipelineText.empty() || PipelineText[0] == ')')
285 return true;
286
287 assert(PipelineText[0] == ',');
288 PipelineText = PipelineText.substr(1);
289 }
290}
291
Chandler Carruth66445382014-01-11 08:16:35 +0000292static bool parseModulePassPipeline(ModulePassManager &MPM,
Chandler Carruth4d356312014-01-20 11:34:08 +0000293 StringRef &PipelineText,
Chandler Carruth14a759e2015-01-13 22:42:38 +0000294 bool VerifyEachPass, bool DebugLogging) {
Chandler Carruth66445382014-01-11 08:16:35 +0000295 for (;;) {
296 // Parse nested pass managers by recursing.
297 if (PipelineText.startswith("module(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000298 ModulePassManager NestedMPM(DebugLogging);
Chandler Carruth258dbb32014-01-11 12:06:47 +0000299
300 // Parse the inner pipeline into the nested manager.
Chandler Carruth66445382014-01-11 08:16:35 +0000301 PipelineText = PipelineText.substr(strlen("module("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000302 if (!parseModulePassPipeline(NestedMPM, PipelineText, VerifyEachPass,
303 DebugLogging) ||
Chandler Carruth6546cb62014-01-12 10:02:02 +0000304 PipelineText.empty())
Chandler Carruth66445382014-01-11 08:16:35 +0000305 return false;
Chandler Carruth6546cb62014-01-12 10:02:02 +0000306 assert(PipelineText[0] == ')');
Chandler Carruth66445382014-01-11 08:16:35 +0000307 PipelineText = PipelineText.substr(1);
Chandler Carruth258dbb32014-01-11 12:06:47 +0000308
309 // Now add the nested manager as a module pass.
Chandler Carruthc3f3da32014-03-09 11:49:53 +0000310 MPM.addPass(std::move(NestedMPM));
Chandler Carruth572e3402014-04-21 11:12:00 +0000311 } else if (PipelineText.startswith("cgscc(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000312 CGSCCPassManager NestedCGPM(DebugLogging);
Chandler Carruth572e3402014-04-21 11:12:00 +0000313
314 // Parse the inner pipeline inte the nested manager.
315 PipelineText = PipelineText.substr(strlen("cgscc("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000316 if (!parseCGSCCPassPipeline(NestedCGPM, PipelineText, VerifyEachPass,
317 DebugLogging) ||
Chandler Carruth572e3402014-04-21 11:12:00 +0000318 PipelineText.empty())
319 return false;
320 assert(PipelineText[0] == ')');
321 PipelineText = PipelineText.substr(1);
322
323 // Add the nested pass manager with the appropriate adaptor.
324 MPM.addPass(
325 createModuleToPostOrderCGSCCPassAdaptor(std::move(NestedCGPM)));
Chandler Carruthd8330982014-01-12 09:34:22 +0000326 } else if (PipelineText.startswith("function(")) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000327 FunctionPassManager NestedFPM(DebugLogging);
Chandler Carruthd8330982014-01-12 09:34:22 +0000328
329 // Parse the inner pipeline inte the nested manager.
330 PipelineText = PipelineText.substr(strlen("function("));
Chandler Carruth14a759e2015-01-13 22:42:38 +0000331 if (!parseFunctionPassPipeline(NestedFPM, PipelineText, VerifyEachPass,
332 DebugLogging) ||
Chandler Carruth6546cb62014-01-12 10:02:02 +0000333 PipelineText.empty())
Chandler Carruthd8330982014-01-12 09:34:22 +0000334 return false;
Chandler Carruth6546cb62014-01-12 10:02:02 +0000335 assert(PipelineText[0] == ')');
Chandler Carruthd8330982014-01-12 09:34:22 +0000336 PipelineText = PipelineText.substr(1);
337
338 // Add the nested pass manager with the appropriate adaptor.
Chandler Carruthc3f3da32014-03-09 11:49:53 +0000339 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(NestedFPM)));
Chandler Carruth66445382014-01-11 08:16:35 +0000340 } else {
341 // Otherwise try to parse a pass name.
342 size_t End = PipelineText.find_first_of(",)");
343 if (!parseModulePassName(MPM, PipelineText.substr(0, End)))
344 return false;
Chandler Carruth4d356312014-01-20 11:34:08 +0000345 if (VerifyEachPass)
346 MPM.addPass(VerifierPass());
Chandler Carruth66445382014-01-11 08:16:35 +0000347
348 PipelineText = PipelineText.substr(End);
349 }
350
351 if (PipelineText.empty() || PipelineText[0] == ')')
352 return true;
353
354 assert(PipelineText[0] == ',');
355 PipelineText = PipelineText.substr(1);
356 }
357}
358
359// Primary pass pipeline description parsing routine.
360// FIXME: Should this routine accept a TargetMachine or require the caller to
361// pre-populate the analysis managers with target-specific stuff?
Chandler Carruth4d356312014-01-20 11:34:08 +0000362bool llvm::parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText,
Chandler Carruth14a759e2015-01-13 22:42:38 +0000363 bool VerifyEachPass, bool DebugLogging) {
Chandler Carruthea368f12015-01-06 08:37:58 +0000364 // By default, try to parse the pipeline as-if it were within an implicit
365 // 'module(...)' pass pipeline. If this will parse at all, it needs to
366 // consume the entire string.
Chandler Carruth14a759e2015-01-13 22:42:38 +0000367 if (parseModulePassPipeline(MPM, PipelineText, VerifyEachPass, DebugLogging))
Chandler Carruthea368f12015-01-06 08:37:58 +0000368 return PipelineText.empty();
Chandler Carruth66445382014-01-11 08:16:35 +0000369
Chandler Carruthea368f12015-01-06 08:37:58 +0000370 // This isn't parsable as a module pipeline, look for the end of a pass name
371 // and directly drop down to that layer.
Chandler Carruth6546cb62014-01-12 10:02:02 +0000372 StringRef FirstName =
373 PipelineText.substr(0, PipelineText.find_first_of(",)"));
Chandler Carruthea368f12015-01-06 08:37:58 +0000374 assert(!isModulePassName(FirstName) &&
375 "Already handled all module pipeline options.");
Chandler Carruth66445382014-01-11 08:16:35 +0000376
Chandler Carruthea368f12015-01-06 08:37:58 +0000377 // If this looks like a CGSCC pass, parse the whole thing as a CGSCC
378 // pipeline.
Chandler Carruth572e3402014-04-21 11:12:00 +0000379 if (isCGSCCPassName(FirstName)) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000380 CGSCCPassManager CGPM(DebugLogging);
381 if (!parseCGSCCPassPipeline(CGPM, PipelineText, VerifyEachPass,
382 DebugLogging) ||
Chandler Carruth572e3402014-04-21 11:12:00 +0000383 !PipelineText.empty())
384 return false;
385 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
386 return true;
387 }
388
Chandler Carruthea368f12015-01-06 08:37:58 +0000389 // Similarly, if this looks like a Function pass, parse the whole thing as
390 // a Function pipelien.
Chandler Carruthd8330982014-01-12 09:34:22 +0000391 if (isFunctionPassName(FirstName)) {
Chandler Carruth14a759e2015-01-13 22:42:38 +0000392 FunctionPassManager FPM(DebugLogging);
393 if (!parseFunctionPassPipeline(FPM, PipelineText, VerifyEachPass,
394 DebugLogging) ||
Chandler Carruth4d356312014-01-20 11:34:08 +0000395 !PipelineText.empty())
Chandler Carruthd8330982014-01-12 09:34:22 +0000396 return false;
Chandler Carruthc3f3da32014-03-09 11:49:53 +0000397 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
Chandler Carruthd8330982014-01-12 09:34:22 +0000398 return true;
399 }
Chandler Carruth66445382014-01-11 08:16:35 +0000400
401 return false;
402}