llvm.org GIT mirror llvm / dea3b33
Revert "[NewPM] teach -passes= to emit meaningful error messages" This reverts r344519 due to failures in pipeline-parsing test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344524 91177308-0d34-0410-b5e6-96231b3b80d8 Fedor Sergeev 10 months ago
12 changed file(s) with 286 addition(s) and 414 deletion(s). Raw diff Collapse all Expand all
1818 #include "llvm/ADT/Optional.h"
1919 #include "llvm/Analysis/CGSCCPassManager.h"
2020 #include "llvm/IR/PassManager.h"
21 #include "llvm/Support/Error.h"
2221 #include "llvm/Transforms/Instrumentation.h"
2322 #include "llvm/Transforms/Scalar/LoopPassManager.h"
2423 #include
384383 /// If the sequence of passes aren't all the exact same kind of pass, it will
385384 /// be an error. You cannot mix different levels implicitly, you must
386385 /// explicitly form a pass manager in which to nest passes.
387 Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText,
388 bool VerifyEachPass = true,
389 bool DebugLogging = false);
386 bool parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText,
387 bool VerifyEachPass = true, bool DebugLogging = false);
390388
391389 /// {{@ Parse a textual pass pipeline description into a specific PassManager
392390 ///
395393 /// this is the valid pipeline text:
396394 ///
397395 /// function(lpass)
398 Error parsePassPipeline(CGSCCPassManager &CGPM, StringRef PipelineText,
399 bool VerifyEachPass = true,
400 bool DebugLogging = false);
401 Error parsePassPipeline(FunctionPassManager &FPM, StringRef PipelineText,
402 bool VerifyEachPass = true,
403 bool DebugLogging = false);
404 Error parsePassPipeline(LoopPassManager &LPM, StringRef PipelineText,
405 bool VerifyEachPass = true,
406 bool DebugLogging = false);
396 bool parsePassPipeline(CGSCCPassManager &CGPM, StringRef PipelineText,
397 bool VerifyEachPass = true, bool DebugLogging = false);
398 bool parsePassPipeline(FunctionPassManager &FPM, StringRef PipelineText,
399 bool VerifyEachPass = true, bool DebugLogging = false);
400 bool parsePassPipeline(LoopPassManager &LPM, StringRef PipelineText,
401 bool VerifyEachPass = true, bool DebugLogging = false);
407402 /// @}}
408403
409404 /// Parse a textual alias analysis pipeline into the provided AA manager.
421416 /// Returns false if the text cannot be parsed cleanly. The specific state of
422417 /// the \p AA manager is unspecified if such an error is encountered and this
423418 /// returns false.
424 Error parseAAPipeline(AAManager &AA, StringRef PipelineText);
419 bool parseAAPipeline(AAManager &AA, StringRef PipelineText);
425420
426421 /// Register a callback for a default optimizer pipeline extension
427422 /// point
569564 static Optional>
570565 parsePipelineText(StringRef Text);
571566
572 Error parseModulePass(ModulePassManager &MPM, const PipelineElement &E,
573 bool VerifyEachPass, bool DebugLogging);
574 Error parseCGSCCPass(CGSCCPassManager &CGPM, const PipelineElement &E,
567 bool parseModulePass(ModulePassManager &MPM, const PipelineElement &E,
575568 bool VerifyEachPass, bool DebugLogging);
576 Error parseFunctionPass(FunctionPassManager &FPM, const PipelineElement &E,
577 bool VerifyEachPass, bool DebugLogging);
578 Error parseLoopPass(LoopPassManager &LPM, const PipelineElement &E,
569 bool parseCGSCCPass(CGSCCPassManager &CGPM, const PipelineElement &E,
579570 bool VerifyEachPass, bool DebugLogging);
571 bool parseFunctionPass(FunctionPassManager &FPM, const PipelineElement &E,
572 bool VerifyEachPass, bool DebugLogging);
573 bool parseLoopPass(LoopPassManager &LPM, const PipelineElement &E,
574 bool VerifyEachPass, bool DebugLogging);
580575 bool parseAAPassName(AAManager &AA, StringRef Name);
581576
582 Error parseLoopPassPipeline(LoopPassManager &LPM,
577 bool parseLoopPassPipeline(LoopPassManager &LPM,
578 ArrayRef Pipeline,
579 bool VerifyEachPass, bool DebugLogging);
580 bool parseFunctionPassPipeline(FunctionPassManager &FPM,
581 ArrayRef Pipeline,
582 bool VerifyEachPass, bool DebugLogging);
583 bool parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
583584 ArrayRef Pipeline,
584585 bool VerifyEachPass, bool DebugLogging);
585 Error parseFunctionPassPipeline(FunctionPassManager &FPM,
586 ArrayRef Pipeline,
587 bool VerifyEachPass, bool DebugLogging);
588 Error parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
586 bool parseModulePassPipeline(ModulePassManager &MPM,
589587 ArrayRef Pipeline,
590588 bool VerifyEachPass, bool DebugLogging);
591 Error parseModulePassPipeline(ModulePassManager &MPM,
592 ArrayRef Pipeline,
593 bool VerifyEachPass, bool DebugLogging);
594589
595590 void addPGOInstrPasses(ModulePassManager &MPM, bool DebugLogging,
596591 OptimizationLevel Level, bool RunProfileGen,
161161 AAManager AA;
162162
163163 // Parse a custom AA pipeline if asked to.
164 if (auto Err = PB.parseAAPipeline(AA, "default"))
164 if (!PB.parseAAPipeline(AA, "default"))
165165 report_fatal_error("Error parsing default AA pipeline");
166166
167167 LoopAnalysisManager LAM(Conf.DebugPassManager);
220220
221221 // Parse a custom AA pipeline if asked to.
222222 if (!AAPipelineDesc.empty())
223 if (auto Err = PB.parseAAPipeline(AA, AAPipelineDesc))
224 report_fatal_error("unable to parse AA pipeline description '" +
225 AAPipelineDesc + "': " + toString(std::move(Err)));
223 if (!PB.parseAAPipeline(AA, AAPipelineDesc))
224 report_fatal_error("unable to parse AA pipeline description: " +
225 AAPipelineDesc);
226226
227227 LoopAnalysisManager LAM;
228228 FunctionAnalysisManager FAM;
245245 MPM.addPass(VerifierPass());
246246
247247 // Now, add all the passes we've been requested to.
248 if (auto Err = PB.parsePassPipeline(MPM, PipelineDesc))
249 report_fatal_error("unable to parse pass pipeline description '" +
250 PipelineDesc + "': " + toString(std::move(Err)));
248 if (!PB.parsePassPipeline(MPM, PipelineDesc))
249 report_fatal_error("unable to parse pass pipeline description: " +
250 PipelineDesc);
251251
252252 if (!DisableVerify)
253253 MPM.addPass(VerifierPass());
5757 #include "llvm/IR/PassManager.h"
5858 #include "llvm/IR/Verifier.h"
5959 #include "llvm/Support/Debug.h"
60 #include "llvm/Support/FormatVariadic.h"
6160 #include "llvm/Support/Regex.h"
6261 #include "llvm/Target/TargetMachine.h"
6362 #include "llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h"
14021401 return {std::move(ResultPipeline)};
14031402 }
14041403
1405 Error PassBuilder::parseModulePass(ModulePassManager &MPM,
1406 const PipelineElement &E,
1407 bool VerifyEachPass, bool DebugLogging) {
1404 bool PassBuilder::parseModulePass(ModulePassManager &MPM,
1405 const PipelineElement &E, bool VerifyEachPass,
1406 bool DebugLogging) {
14081407 auto &Name = E.Name;
14091408 auto &InnerPipeline = E.InnerPipeline;
14101409
14121411 if (!InnerPipeline.empty()) {
14131412 if (Name == "module") {
14141413 ModulePassManager NestedMPM(DebugLogging);
1415 if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline,
1416 VerifyEachPass, DebugLogging))
1417 return Err;
1414 if (!parseModulePassPipeline(NestedMPM, InnerPipeline, VerifyEachPass,
1415 DebugLogging))
1416 return false;
14181417 MPM.addPass(std::move(NestedMPM));
1419 return Error::success();
1418 return true;
14201419 }
14211420 if (Name == "cgscc") {
14221421 CGSCCPassManager CGPM(DebugLogging);
1423 if (auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline, VerifyEachPass,
1424 DebugLogging))
1425 return Err;
1422 if (!parseCGSCCPassPipeline(CGPM, InnerPipeline, VerifyEachPass,
1423 DebugLogging))
1424 return false;
14261425 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
1427 return Error::success();
1426 return true;
14281427 }
14291428 if (Name == "function") {
14301429 FunctionPassManager FPM(DebugLogging);
1431 if (auto Err = parseFunctionPassPipeline(FPM, InnerPipeline,
1432 VerifyEachPass, DebugLogging))
1433 return Err;
1430 if (!parseFunctionPassPipeline(FPM, InnerPipeline, VerifyEachPass,
1431 DebugLogging))
1432 return false;
14341433 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
1435 return Error::success();
1434 return true;
14361435 }
14371436 if (auto Count = parseRepeatPassName(Name)) {
14381437 ModulePassManager NestedMPM(DebugLogging);
1439 if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline,
1440 VerifyEachPass, DebugLogging))
1441 return Err;
1438 if (!parseModulePassPipeline(NestedMPM, InnerPipeline, VerifyEachPass,
1439 DebugLogging))
1440 return false;
14421441 MPM.addPass(createRepeatedPass(*Count, std::move(NestedMPM)));
1443 return Error::success();
1442 return true;
14441443 }
14451444
14461445 for (auto &C : ModulePipelineParsingCallbacks)
14471446 if (C(Name, MPM, InnerPipeline))
1448 return Error::success();
1447 return true;
14491448
14501449 // Normal passes can't have pipelines.
1451 return make_error(
1452 formatv("invalid use of '{0}' pass as module pipeline", Name).str(),
1453 inconvertibleErrorCode());
1454 ;
1450 return false;
14551451 }
14561452
14571453 // Manually handle aliases for pre-configured pipeline fragments.
14581454 if (startsWithDefaultPipelineAliasPrefix(Name)) {
14591455 SmallVector Matches;
14601456 if (!DefaultAliasRegex.match(Name, &Matches))
1461 return make_error(
1462 formatv("unknown default pipeline alias '{0}'", Name).str(),
1463 inconvertibleErrorCode());
1464
1457 return false;
14651458 assert(Matches.size() == 3 && "Must capture two matched strings!");
14661459
14671460 OptimizationLevel L = StringSwitch(Matches[2])
14731466 .Case("Oz", Oz);
14741467 if (L == O0)
14751468 // At O0 we do nothing at all!
1476 return Error::success();
1469 return true;
14771470
14781471 if (Matches[1] == "default") {
14791472 MPM.addPass(buildPerModuleDefaultPipeline(L, DebugLogging));
14871480 assert(Matches[1] == "lto" && "Not one of the matched options!");
14881481 MPM.addPass(buildLTODefaultPipeline(L, DebugLogging, nullptr));
14891482 }
1490 return Error::success();
1483 return true;
14911484 }
14921485
14931486 // Finally expand the basic registered passes from the .inc file.
14941487 #define MODULE_PASS(NAME, CREATE_PASS) \
14951488 if (Name == NAME) { \
14961489 MPM.addPass(CREATE_PASS); \
1497 return Error::success(); \
1490 return true; \
14981491 }
14991492 #define MODULE_ANALYSIS(NAME, CREATE_PASS) \
15001493 if (Name == "require<" NAME ">") { \
15011494 MPM.addPass( \
15021495 RequireAnalysisPass< \
15031496 std::remove_reference::type, Module>()); \
1504 return Error::success(); \
1497 return true; \
15051498 } \
15061499 if (Name == "invalidate<" NAME ">") { \
15071500 MPM.addPass(InvalidateAnalysisPass< \
15081501 std::remove_reference::type>()); \
1509 return Error::success(); \
1502 return true; \
15101503 }
15111504 #include "PassRegistry.def"
15121505
15131506 for (auto &C : ModulePipelineParsingCallbacks)
15141507 if (C(Name, MPM, InnerPipeline))
1515 return Error::success();
1516 return make_error(
1517 formatv("unknown module pass '{0}'", Name).str(),
1518 inconvertibleErrorCode());
1519 }
1520
1521 Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM,
1522 const PipelineElement &E, bool VerifyEachPass,
1523 bool DebugLogging) {
1508 return true;
1509 return false;
1510 }
1511
1512 bool PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM,
1513 const PipelineElement &E, bool VerifyEachPass,
1514 bool DebugLogging) {
15241515 auto &Name = E.Name;
15251516 auto &InnerPipeline = E.InnerPipeline;
15261517
15281519 if (!InnerPipeline.empty()) {
15291520 if (Name == "cgscc") {
15301521 CGSCCPassManager NestedCGPM(DebugLogging);
1531 if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline,
1532 VerifyEachPass, DebugLogging))
1533 return Err;
1522 if (!parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, VerifyEachPass,
1523 DebugLogging))
1524 return false;
15341525 // Add the nested pass manager with the appropriate adaptor.
15351526 CGPM.addPass(std::move(NestedCGPM));
1536 return Error::success();
1527 return true;
15371528 }
15381529 if (Name == "function") {
15391530 FunctionPassManager FPM(DebugLogging);
1540 if (auto Err = parseFunctionPassPipeline(FPM, InnerPipeline,
1541 VerifyEachPass, DebugLogging))
1542 return Err;
1531 if (!parseFunctionPassPipeline(FPM, InnerPipeline, VerifyEachPass,
1532 DebugLogging))
1533 return false;
15431534 // Add the nested pass manager with the appropriate adaptor.
15441535 CGPM.addPass(createCGSCCToFunctionPassAdaptor(std::move(FPM)));
1545 return Error::success();
1536 return true;
15461537 }
15471538 if (auto Count = parseRepeatPassName(Name)) {
15481539 CGSCCPassManager NestedCGPM(DebugLogging);
1549 if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline,
1550 VerifyEachPass, DebugLogging))
1551 return Err;
1540 if (!parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, VerifyEachPass,
1541 DebugLogging))
1542 return false;
15521543 CGPM.addPass(createRepeatedPass(*Count, std::move(NestedCGPM)));
1553 return Error::success();
1544 return true;
15541545 }
15551546 if (auto MaxRepetitions = parseDevirtPassName(Name)) {
15561547 CGSCCPassManager NestedCGPM(DebugLogging);
1557 if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline,
1558 VerifyEachPass, DebugLogging))
1559 return Err;
1548 if (!parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, VerifyEachPass,
1549 DebugLogging))
1550 return false;
15601551 CGPM.addPass(
15611552 createDevirtSCCRepeatedPass(std::move(NestedCGPM), *MaxRepetitions));
1562 return Error::success();
1553 return true;
15631554 }
15641555
15651556 for (auto &C : CGSCCPipelineParsingCallbacks)
15661557 if (C(Name, CGPM, InnerPipeline))
1567 return Error::success();
1558 return true;
15681559
15691560 // Normal passes can't have pipelines.
1570 return make_error(
1571 formatv("invalid use of '{0}' pass as cgscc pipeline", Name).str(),
1572 inconvertibleErrorCode());
1561 return false;
15731562 }
15741563
15751564 // Now expand the basic registered passes from the .inc file.
15761565 #define CGSCC_PASS(NAME, CREATE_PASS) \
15771566 if (Name == NAME) { \
15781567 CGPM.addPass(CREATE_PASS); \
1579 return Error::success(); \
1568 return true; \
15801569 }
15811570 #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
15821571 if (Name == "require<" NAME ">") { \
15841573 std::remove_reference::type, \
15851574 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
15861575 CGSCCUpdateResult &>()); \
1587 return Error::success(); \
1576 return true; \
15881577 } \
15891578 if (Name == "invalidate<" NAME ">") { \
15901579 CGPM.addPass(InvalidateAnalysisPass< \
15911580 std::remove_reference::type>()); \
1592 return Error::success(); \
1581 return true; \
15931582 }
15941583 #include "PassRegistry.def"
15951584
15961585 for (auto &C : CGSCCPipelineParsingCallbacks)
15971586 if (C(Name, CGPM, InnerPipeline))
1598 return Error::success();
1599 return make_error(
1600 formatv("unknown cgscc pass '{0}'", Name).str(),
1601 inconvertibleErrorCode());
1602 }
1603
1604 Error PassBuilder::parseFunctionPass(FunctionPassManager &FPM,
1605 const PipelineElement &E,
1606 bool VerifyEachPass, bool DebugLogging) {
1587 return true;
1588 return false;
1589 }
1590
1591 bool PassBuilder::parseFunctionPass(FunctionPassManager &FPM,
1592 const PipelineElement &E,
1593 bool VerifyEachPass, bool DebugLogging) {
16071594 auto &Name = E.Name;
16081595 auto &InnerPipeline = E.InnerPipeline;
16091596
16111598 if (!InnerPipeline.empty()) {
16121599 if (Name == "function") {
16131600 FunctionPassManager NestedFPM(DebugLogging);
1614 if (auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline,
1615 VerifyEachPass, DebugLogging))
1616 return Err;
1601 if (!parseFunctionPassPipeline(NestedFPM, InnerPipeline, VerifyEachPass,
1602 DebugLogging))
1603 return false;
16171604 // Add the nested pass manager with the appropriate adaptor.
16181605 FPM.addPass(std::move(NestedFPM));
1619 return Error::success();
1606 return true;
16201607 }
16211608 if (Name == "loop") {
16221609 LoopPassManager LPM(DebugLogging);
1623 if (auto Err = parseLoopPassPipeline(LPM, InnerPipeline, VerifyEachPass,
1624 DebugLogging))
1625 return Err;
1610 if (!parseLoopPassPipeline(LPM, InnerPipeline, VerifyEachPass,
1611 DebugLogging))
1612 return false;
16261613 // Add the nested pass manager with the appropriate adaptor.
16271614 FPM.addPass(
16281615 createFunctionToLoopPassAdaptor(std::move(LPM), DebugLogging));
1629 return Error::success();
1616 return true;
16301617 }
16311618 if (auto Count = parseRepeatPassName(Name)) {
16321619 FunctionPassManager NestedFPM(DebugLogging);
1633 if (auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline,
1634 VerifyEachPass, DebugLogging))
1635 return Err;
1620 if (!parseFunctionPassPipeline(NestedFPM, InnerPipeline, VerifyEachPass,
1621 DebugLogging))
1622 return false;
16361623 FPM.addPass(createRepeatedPass(*Count, std::move(NestedFPM)));
1637 return Error::success();
1624 return true;
16381625 }
16391626
16401627 for (auto &C : FunctionPipelineParsingCallbacks)
16411628 if (C(Name, FPM, InnerPipeline))
1642 return Error::success();
1629 return true;
16431630
16441631 // Normal passes can't have pipelines.
1645 return make_error(
1646 formatv("invalid use of '{0}' pass as function pipeline", Name).str(),
1647 inconvertibleErrorCode());
1632 return false;
16481633 }
16491634
16501635 // Now expand the basic registered passes from the .inc file.
16511636 #define FUNCTION_PASS(NAME, CREATE_PASS) \
16521637 if (Name == NAME) { \
16531638 FPM.addPass(CREATE_PASS); \
1654 return Error::success(); \
1639 return true; \
16551640 }
16561641 #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
16571642 if (Name == "require<" NAME ">") { \
16581643 FPM.addPass( \
16591644 RequireAnalysisPass< \
16601645 std::remove_reference::type, Function>()); \
1661 return Error::success(); \
1646 return true; \
16621647 } \
16631648 if (Name == "invalidate<" NAME ">") { \
16641649 FPM.addPass(InvalidateAnalysisPass< \
16651650 std::remove_reference::type>()); \
1666 return Error::success(); \
1651 return true; \
16671652 }
16681653 #include "PassRegistry.def"
16691654
16701655 for (auto &C : FunctionPipelineParsingCallbacks)
16711656 if (C(Name, FPM, InnerPipeline))
1672 return Error::success();
1673 return make_error(
1674 formatv("unknown function pass '{0}'", Name).str(),
1675 inconvertibleErrorCode());
1676 }
1677
1678 Error PassBuilder::parseLoopPass(LoopPassManager &LPM, const PipelineElement &E,
1679 bool VerifyEachPass, bool DebugLogging) {
1657 return true;
1658 return false;
1659 }
1660
1661 bool PassBuilder::parseLoopPass(LoopPassManager &LPM, const PipelineElement &E,
1662 bool VerifyEachPass, bool DebugLogging) {
16801663 StringRef Name = E.Name;
16811664 auto &InnerPipeline = E.InnerPipeline;
16821665
16841667 if (!InnerPipeline.empty()) {
16851668 if (Name == "loop") {
16861669 LoopPassManager NestedLPM(DebugLogging);
1687 if (auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline,
1688 VerifyEachPass, DebugLogging))
1689 return Err;
1670 if (!parseLoopPassPipeline(NestedLPM, InnerPipeline, VerifyEachPass,
1671 DebugLogging))
1672 return false;
16901673 // Add the nested pass manager with the appropriate adaptor.
16911674 LPM.addPass(std::move(NestedLPM));
1692 return Error::success();
1675 return true;
16931676 }
16941677 if (auto Count = parseRepeatPassName(Name)) {
16951678 LoopPassManager NestedLPM(DebugLogging);
1696 if (auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline,
1697 VerifyEachPass, DebugLogging))
1698 return Err;
1679 if (!parseLoopPassPipeline(NestedLPM, InnerPipeline, VerifyEachPass,
1680 DebugLogging))
1681 return false;
16991682 LPM.addPass(createRepeatedPass(*Count, std::move(NestedLPM)));
1700 return Error::success();
1683 return true;
17011684 }
17021685
17031686 for (auto &C : LoopPipelineParsingCallbacks)
17041687 if (C(Name, LPM, InnerPipeline))
1705 return Error::success();
1688 return true;
17061689
17071690 // Normal passes can't have pipelines.
1708 return make_error(
1709 formatv("invalid use of '{0}' pass as loop pipeline", Name).str(),
1710 inconvertibleErrorCode());
1691 return false;
17111692 }
17121693
17131694 // Now expand the basic registered passes from the .inc file.
17141695 #define LOOP_PASS(NAME, CREATE_PASS) \
17151696 if (Name == NAME) { \
17161697 LPM.addPass(CREATE_PASS); \
1717 return Error::success(); \
1698 return true; \
17181699 }
17191700 #define LOOP_ANALYSIS(NAME, CREATE_PASS) \
17201701 if (Name == "require<" NAME ">") { \
17221703 std::remove_reference::type, Loop, \
17231704 LoopAnalysisManager, LoopStandardAnalysisResults &, \
17241705 LPMUpdater &>()); \
1725 return Error::success(); \
1706 return true; \
17261707 } \
17271708 if (Name == "invalidate<" NAME ">") { \
17281709 LPM.addPass(InvalidateAnalysisPass< \
17291710 std::remove_reference::type>()); \
1730 return Error::success(); \
1711 return true; \
17311712 }
17321713 #include "PassRegistry.def"
17331714
17341715 for (auto &C : LoopPipelineParsingCallbacks)
17351716 if (C(Name, LPM, InnerPipeline))
1736 return Error::success();
1737 return make_error(formatv("unknown loop pass '{0}'", Name).str(),
1738 inconvertibleErrorCode());
1717 return true;
1718 return false;
17391719 }
17401720
17411721 bool PassBuilder::parseAAPassName(AAManager &AA, StringRef Name) {
17591739 return false;
17601740 }
17611741
1762 Error PassBuilder::parseLoopPassPipeline(LoopPassManager &LPM,
1742 bool PassBuilder::parseLoopPassPipeline(LoopPassManager &LPM,
1743 ArrayRef Pipeline,
1744 bool VerifyEachPass,
1745 bool DebugLogging) {
1746 for (const auto &Element : Pipeline) {
1747 if (!parseLoopPass(LPM, Element, VerifyEachPass, DebugLogging))
1748 return false;
1749 // FIXME: No verifier support for Loop passes!
1750 }
1751 return true;
1752 }
1753
1754 bool PassBuilder::parseFunctionPassPipeline(FunctionPassManager &FPM,
1755 ArrayRef Pipeline,
1756 bool VerifyEachPass,
1757 bool DebugLogging) {
1758 for (const auto &Element : Pipeline) {
1759 if (!parseFunctionPass(FPM, Element, VerifyEachPass, DebugLogging))
1760 return false;
1761 if (VerifyEachPass)
1762 FPM.addPass(VerifierPass());
1763 }
1764 return true;
1765 }
1766
1767 bool PassBuilder::parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
17631768 ArrayRef Pipeline,
17641769 bool VerifyEachPass,
17651770 bool DebugLogging) {
17661771 for (const auto &Element : Pipeline) {
1767 if (auto Err = parseLoopPass(LPM, Element, VerifyEachPass, DebugLogging))
1768 return Err;
1769 // FIXME: No verifier support for Loop passes!
1770 }
1771 return Error::success();
1772 }
1773
1774 Error PassBuilder::parseFunctionPassPipeline(FunctionPassManager &FPM,
1775 ArrayRef Pipeline,
1776 bool VerifyEachPass,
1777 bool DebugLogging) {
1778 for (const auto &Element : Pipeline) {
1779 if (auto Err =
1780 parseFunctionPass(FPM, Element, VerifyEachPass, DebugLogging))
1781 return Err;
1782 if (VerifyEachPass)
1783 FPM.addPass(VerifierPass());
1784 }
1785 return Error::success();
1786 }
1787
1788 Error PassBuilder::parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
1789 ArrayRef Pipeline,
1790 bool VerifyEachPass,
1791 bool DebugLogging) {
1792 for (const auto &Element : Pipeline) {
1793 if (auto Err = parseCGSCCPass(CGPM, Element, VerifyEachPass, DebugLogging))
1794 return Err;
1772 if (!parseCGSCCPass(CGPM, Element, VerifyEachPass, DebugLogging))
1773 return false;
17951774 // FIXME: No verifier support for CGSCC passes!
17961775 }
1797 return Error::success();
1776 return true;
17981777 }
17991778
18001779 void PassBuilder::crossRegisterProxies(LoopAnalysisManager &LAM,
18101789 LAM.registerPass([&] { return FunctionAnalysisManagerLoopProxy(FAM); });
18111790 }
18121791
1813 Error PassBuilder::parseModulePassPipeline(ModulePassManager &MPM,
1814 ArrayRef Pipeline,
1815 bool VerifyEachPass,
1816 bool DebugLogging) {
1792 bool PassBuilder::parseModulePassPipeline(ModulePassManager &MPM,
1793 ArrayRef Pipeline,
1794 bool VerifyEachPass,
1795 bool DebugLogging) {
18171796 for (const auto &Element : Pipeline) {
1818 if (auto Err = parseModulePass(MPM, Element, VerifyEachPass, DebugLogging))
1819 return Err;
1797 if (!parseModulePass(MPM, Element, VerifyEachPass, DebugLogging))
1798 return false;
18201799 if (VerifyEachPass)
18211800 MPM.addPass(VerifierPass());
18221801 }
1823 return Error::success();
1802 return true;
18241803 }
18251804
18261805 // Primary pass pipeline description parsing routine for a \c ModulePassManager
18271806 // FIXME: Should this routine accept a TargetMachine or require the caller to
18281807 // pre-populate the analysis managers with target-specific stuff?
1829 Error PassBuilder::parsePassPipeline(ModulePassManager &MPM,
1830 StringRef PipelineText,
1831 bool VerifyEachPass, bool DebugLogging) {
1808 bool PassBuilder::parsePassPipeline(ModulePassManager &MPM,
1809 StringRef PipelineText, bool VerifyEachPass,
1810 bool DebugLogging) {
18321811 auto Pipeline = parsePipelineText(PipelineText);
18331812 if (!Pipeline || Pipeline->empty())
1834 return make_error(
1835 formatv("invalid pipeline '{0}'", PipelineText).str(),
1836 inconvertibleErrorCode());
1813 return false;
18371814
18381815 // If the first name isn't at the module layer, wrap the pipeline up
18391816 // automatically.
18501827 } else {
18511828 for (auto &C : TopLevelPipelineParsingCallbacks)
18521829 if (C(MPM, *Pipeline, VerifyEachPass, DebugLogging))
1853 return Error::success();
1854
1855 // Unknown pass or pipeline name!
1856 auto &InnerPipeline = Pipeline->front().InnerPipeline;
1857 return make_error(
1858 formatv("unknown {0} name '{1}'",
1859 (InnerPipeline.empty() ? "pass" : "pipeline"), FirstName)
1860 .str(),
1861 inconvertibleErrorCode());
1830 return true;
1831
1832 // Unknown pass name!
1833 return false;
18621834 }
18631835 }
18641836
1865 if (auto Err =
1866 parseModulePassPipeline(MPM, *Pipeline, VerifyEachPass, DebugLogging))
1867 return Err;
1868 return Error::success();
1837 return parseModulePassPipeline(MPM, *Pipeline, VerifyEachPass, DebugLogging);
18691838 }
18701839
18711840 // Primary pass pipeline description parsing routine for a \c CGSCCPassManager
1872 Error PassBuilder::parsePassPipeline(CGSCCPassManager &CGPM,
1873 StringRef PipelineText,
1874 bool VerifyEachPass, bool DebugLogging) {
1841 bool PassBuilder::parsePassPipeline(CGSCCPassManager &CGPM,
1842 StringRef PipelineText, bool VerifyEachPass,
1843 bool DebugLogging) {
18751844 auto Pipeline = parsePipelineText(PipelineText);
18761845 if (!Pipeline || Pipeline->empty())
1877 return make_error(
1878 formatv("invalid pipeline '{0}'", PipelineText).str(),
1879 inconvertibleErrorCode());
1846 return false;
18801847
18811848 StringRef FirstName = Pipeline->front().Name;
18821849 if (!isCGSCCPassName(FirstName, CGSCCPipelineParsingCallbacks))
1883 return make_error(
1884 formatv("unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
1885 PipelineText)
1886 .str(),
1887 inconvertibleErrorCode());
1888
1889 if (auto Err =
1890 parseCGSCCPassPipeline(CGPM, *Pipeline, VerifyEachPass, DebugLogging))
1891 return Err;
1892 return Error::success();
1850 return false;
1851
1852 return parseCGSCCPassPipeline(CGPM, *Pipeline, VerifyEachPass, DebugLogging);
18931853 }
18941854
18951855 // Primary pass pipeline description parsing routine for a \c
18961856 // FunctionPassManager
1897 Error PassBuilder::parsePassPipeline(FunctionPassManager &FPM,
1898 StringRef PipelineText,
1899 bool VerifyEachPass, bool DebugLogging) {
1857 bool PassBuilder::parsePassPipeline(FunctionPassManager &FPM,
1858 StringRef PipelineText, bool VerifyEachPass,
1859 bool DebugLogging) {
19001860 auto Pipeline = parsePipelineText(PipelineText);
19011861 if (!Pipeline || Pipeline->empty())
1902 return make_error(
1903 formatv("invalid pipeline '{0}'", PipelineText).str(),
1904 inconvertibleErrorCode());
1862 return false;
19051863
19061864 StringRef FirstName = Pipeline->front().Name;
19071865 if (!isFunctionPassName(FirstName, FunctionPipelineParsingCallbacks))
1908 return make_error(
1909 formatv("unknown function pass '{0}' in pipeline '{1}'", FirstName,
1910 PipelineText)
1911 .str(),
1912 inconvertibleErrorCode());
1913
1914 if (auto Err = parseFunctionPassPipeline(FPM, *Pipeline, VerifyEachPass,
1915 DebugLogging))
1916 return Err;
1917 return Error::success();
1866 return false;
1867
1868 return parseFunctionPassPipeline(FPM, *Pipeline, VerifyEachPass,
1869 DebugLogging);
19181870 }
19191871
19201872 // Primary pass pipeline description parsing routine for a \c LoopPassManager
1921 Error PassBuilder::parsePassPipeline(LoopPassManager &CGPM,
1922 StringRef PipelineText,
1923 bool VerifyEachPass, bool DebugLogging) {
1873 bool PassBuilder::parsePassPipeline(LoopPassManager &CGPM,
1874 StringRef PipelineText, bool VerifyEachPass,
1875 bool DebugLogging) {
19241876 auto Pipeline = parsePipelineText(PipelineText);
19251877 if (!Pipeline || Pipeline->empty())
1926 return make_error(
1927 formatv("invalid pipeline '{0}'", PipelineText).str(),
1928 inconvertibleErrorCode());
1929
1930 if (auto Err =
1931 parseLoopPassPipeline(CGPM, *Pipeline, VerifyEachPass, DebugLogging))
1932 return Err;
1933
1934 return Error::success();
1935 }
1936
1937 Error PassBuilder::parseAAPipeline(AAManager &AA, StringRef PipelineText) {
1878 return false;
1879
1880 return parseLoopPassPipeline(CGPM, *Pipeline, VerifyEachPass, DebugLogging);
1881 }
1882
1883 bool PassBuilder::parseAAPipeline(AAManager &AA, StringRef PipelineText) {
19381884 // If the pipeline just consists of the word 'default' just replace the AA
19391885 // manager with our default one.
19401886 if (PipelineText == "default") {
19411887 AA = buildDefaultAAPipeline();
1942 return Error::success();
1888 return true;
19431889 }
19441890
19451891 while (!PipelineText.empty()) {
19461892 StringRef Name;
19471893 std::tie(Name, PipelineText) = PipelineText.split(',');
19481894 if (!parseAAPassName(AA, Name))
1949 return make_error(
1950 formatv("unknown alias analysis name '{0}'", Name).str(),
1951 inconvertibleErrorCode());
1952 }
1953
1954 return Error::success();
1955 }
1895 return false;
1896 }
1897
1898 return true;
1899 }
5353 ; RUN: not opt -disable-output -debug-pass-manager \
5454 ; RUN: -passes='no-op-module)' %s 2>&1 \
5555 ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED1
56 ; CHECK-UNBALANCED1: invalid pipeline 'no-op-module)'
56 ; CHECK-UNBALANCED1: unable to parse pass pipeline description
5757
5858 ; RUN: not opt -disable-output -debug-pass-manager \
5959 ; RUN: -passes='module(no-op-module))' %s 2>&1 \
6060 ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED2
61 ; CHECK-UNBALANCED2: invalid pipeline 'module(no-op-module))'
61 ; CHECK-UNBALANCED2: unable to parse pass pipeline description
6262
6363 ; RUN: not opt -disable-output -debug-pass-manager \
6464 ; RUN: -passes='module(no-op-module' %s 2>&1 \
6565 ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED3
66 ; CHECK-UNBALANCED3: invalid pipeline 'module(no-op-module'
66 ; CHECK-UNBALANCED3: unable to parse pass pipeline description
6767
6868 ; RUN: not opt -disable-output -debug-pass-manager \
6969 ; RUN: -passes='no-op-function)' %s 2>&1 \
7070 ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED4
71 ; CHECK-UNBALANCED4: invalid pipeline 'no-op-function)'
71 ; CHECK-UNBALANCED4: unable to parse pass pipeline description
7272
7373 ; RUN: not opt -disable-output -debug-pass-manager \
7474 ; RUN: -passes='function(no-op-function))' %s 2>&1 \
7575 ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED5
76 ; CHECK-UNBALANCED5: invalid pipeline 'function(no-op-function))'
76 ; CHECK-UNBALANCED5: unable to parse pass pipeline description
7777
7878 ; RUN: not opt -disable-output -debug-pass-manager \
7979 ; RUN: -passes='function(function(no-op-function)))' %s 2>&1 \
8080 ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED6
81 ; CHECK-UNBALANCED6: invalid pipeline 'function(function(no-op-function)))'
81 ; CHECK-UNBALANCED6: unable to parse pass pipeline description
8282
8383 ; RUN: not opt -disable-output -debug-pass-manager \
8484 ; RUN: -passes='function(no-op-function' %s 2>&1 \
8585 ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED7
86 ; CHECK-UNBALANCED7: invalid pipeline 'function(no-op-function'
86 ; CHECK-UNBALANCED7: unable to parse pass pipeline description
8787
8888 ; RUN: not opt -disable-output -debug-pass-manager \
8989 ; RUN: -passes='function(function(no-op-function)' %s 2>&1 \
9090 ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED8
91 ; CHECK-UNBALANCED8: invalid pipeline 'function(function(no-op-function)'
91 ; CHECK-UNBALANCED8: unable to parse pass pipeline description
9292
9393 ; RUN: not opt -disable-output -debug-pass-manager \
9494 ; RUN: -passes='no-op-module,)' %s 2>&1 \
9595 ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED9
96 ; CHECK-UNBALANCED9: invalid pipeline 'no-op-module,)'
96 ; CHECK-UNBALANCED9: unable to parse pass pipeline description
9797
9898 ; RUN: not opt -disable-output -debug-pass-manager \
9999 ; RUN: -passes='no-op-function,)' %s 2>&1 \
100100 ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED10
101 ; CHECK-UNBALANCED10: invalid pipeline 'no-op-function,)'
101 ; CHECK-UNBALANCED10: unable to parse pass pipeline description
102102
103103 ; RUN: opt -disable-output -debug-pass-manager \
104104 ; RUN: -passes=no-op-cgscc,no-op-cgscc %s 2>&1 \
175175 ; RUN: not opt -disable-output -debug-pass-manager \
176176 ; RUN: -passes='function(no-op-function)function(no-op-function)' %s 2>&1 \
177177 ; RUN: | FileCheck %s --check-prefix=CHECK-MISSING-COMMA1
178 ; CHECK-MISSING-COMMA1: invalid pipeline 'function(no-op-function)function(no-op-function)'
178 ; CHECK-MISSING-COMMA1: unable to parse pass pipeline description
179179
180180 ; RUN: not opt -disable-output -debug-pass-manager \
181181 ; RUN: -passes='function()' %s 2>&1 \
182182 ; RUN: | FileCheck %s --check-prefix=CHECK-EMPTY-INNER-PIPELINE
183 ; CHECK-EMPTY-INNER-PIPELINE: unknown function pass ''
183 ; CHECK-EMPTY-INNER-PIPELINE: unable to parse pass pipeline description
184184
185185 ; RUN: not opt -disable-output -debug-pass-manager \
186186 ; RUN: -passes='no-op-module(no-op-module,whatever)' %s 2>&1 \
187187 ; RUN: | FileCheck %s --check-prefix=CHECK-PIPELINE-ON-MODULE-PASS
188 ; CHECK-PIPELINE-ON-MODULE-PASS: invalid use of 'no-op-module' pass as module pipeline
188 ; CHECK-PIPELINE-ON-MODULE-PASS: unable to parse pass pipeline description
189189
190190 ; RUN: not opt -disable-output -debug-pass-manager \
191191 ; RUN: -passes='no-op-cgscc(no-op-cgscc,whatever)' %s 2>&1 \
192192 ; RUN: | FileCheck %s --check-prefix=CHECK-PIPELINE-ON-CGSCC-PASS
193 ; CHECK-PIPELINE-ON-CGSCC-PASS: invalid use of 'no-op-cgscc' pass as cgscc pipeline
193 ; CHECK-PIPELINE-ON-CGSCC-PASS: unable to parse pass pipeline description
194194
195195 ; RUN: not opt -disable-output -debug-pass-manager \
196196 ; RUN: -passes='no-op-function(no-op-function,whatever)' %s 2>&1 \
197197 ; RUN: | FileCheck %s --check-prefix=CHECK-PIPELINE-ON-FUNCTION-PASS
198 ; CHECK-PIPELINE-ON-FUNCTION-PASS: invalid use of 'no-op-function' pass as function pipeline
198 ; CHECK-PIPELINE-ON-FUNCTION-PASS: unable to parse pass pipeline description
199199
200200 ; RUN: not opt -disable-output -debug-pass-manager \
201201 ; RUN: -passes='no-op-loop(no-op-loop,whatever)' %s 2>&1 \
202202 ; RUN: | FileCheck %s --check-prefix=CHECK-PIPELINE-ON-LOOP-PASS
203 ; CHECK-PIPELINE-ON-LOOP-PASS: invalid use of 'no-op-loop' pass as loop pipeline
203 ; CHECK-PIPELINE-ON-LOOP-PASS: unable to parse pass pipeline description
204204
205205 ; RUN: not opt -disable-output -debug-pass-manager \
206206 ; RUN: -passes='no-op-function()' %s 2>&1 \
207207 ; RUN: | FileCheck %s --check-prefix=CHECK-EMPTY-PIPELINE-ON-PASS
208 ; CHECK-EMPTY-PIPELINE-ON-PASS: invalid use of 'no-op-function' pass as function pipeline
209
210 ; RUN: not opt -passes='no-op-module,bad' \
211 ; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-UNKNOWN-MODULE
212 ; CHECK-UNKNOWN-MODULE: opt: unknown module pass 'bad'
213
214 ; RUN: not opt -passes='no-op-loop,bad' \
215 ; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-UNKNOWN-LOOP
216 ; CHECK-UNKNOWN-LOOP: opt: unknown loop pass 'bad'
217
218 ; RUN: not opt -passes='no-op-cgscc,bad' \
219 ; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-UNKNOWN-CGSCC
220 ; CHECK-UNKNOWN-CGSCC: opt: unknown cgscc pass 'bad'
221
222 ; RUN: not opt -passes='no-op-function,bad' \
223 ; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-UNKNOWN-FUNCTION
224 ; RUN: not opt -passes='function(bad,pipeline,text)' \
225 ; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-UNKNOWN-FUNCTION
226 ; RUN: not opt -passes='module(no-op-module,function(bad,pipeline,text))' \
227 ; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-UNKNOWN-FUNCTION
228 ; RUN: not opt -passes='no-op-module,function(bad,pipeline,text)' \
229 ; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-UNKNOWN-FUNCTION
230 ; RUN: not opt -passes='module(cgscc(function(bad,pipeline,text)))' \
231 ; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-UNKNOWN-FUNCTION
232 ; CHECK-UNKNOWN-FUNCTION: opt: unknown function pass 'bad'
233
234 ; RUN: not opt -aa-pipeline=bad -passes=no-op-function \
235 ; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=AA-PIPELINE-ERR
236 ; AA-PIPELINE-ERR: unknown alias analysis name 'bad'
237 ; RUN: opt -passes-ep-peephole=bad -passes=no-op-function \
238 ; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=PASSES-EP-PEEPHOLE-ERR
239 ; PASSES-EP-PEEPHOLE-ERR: Could not parse pipeline 'bad'. I'm going to ignore it.
240 ; RUN: opt -passes-ep-late-loop-optimizations=bad -passes=no-op-function \
241 ; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=PASSES-EP-LATELOOPOPT-ERR
242 ; PASSES-EP-LATELOOPOPT-ERR: Could not parse pipeline 'bad'. I'm going to ignore it.
243 ; RUN: opt -passes-ep-loop-optimizer-end=bad -passes=no-op-function \
244 ; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=PASSES-EP-LOOPOPTEND-ERR
245 ; PASSES-EP-LOOPOPTEND-ERR: Could not parse pipeline 'bad'. I'm going to ignore it.
246 ; RUN: opt -passes-ep-scalar-optimizer-late=bad -passes=no-op-function \
247 ; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=PASSES-EP-SCALAROPTLATE-ERR
248 ; PASSES-EP-SCALAROPTLATE-ERR: Could not parse pipeline 'bad'. I'm going to ignore it.
249 ; RUN: opt -passes-ep-cgscc-optimizer-late=bad -passes=no-op-function \
250 ; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=PASSES-EP-CGSCCOPTLATE-ERR
251 ; PASSES-EP-CGSCCOPTLATE-ERR: Could not parse pipeline 'bad'. I'm going to ignore it.
252 ; RUN: opt -passes-ep-vectorizer-start=bad -passes=no-op-function \
253 ; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=PASSES-EP-VECTORIZERSTART-ERR
254 ; PASSES-EP-VECTORIZERSTART-ERR: Could not parse pipeline 'bad'. I'm going to ignore it.
255 ; RUN: opt -passes-ep-pipeline-start=bad -passes=no-op-function \
256 ; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=PASSES-EP-PIPELINESTART-ERR
257 ; PASSES-EP-PIPELINESTART-ERR: Could not parse pipeline 'bad'. I'm going to ignore it.
208 ; CHECK-EMPTY-PIPELINE-ON-PASS: unable to parse pass pipeline description
258209
259210 define void @f() {
260211 entry:
3131 ; RUN: -r %t1.bc,patatino,px -opt-pipeline foogoo 2>&1 | \
3232 ; RUN: FileCheck %s --check-prefix=ERR
3333
34 ; ERR: LLVM ERROR: unable to parse pass pipeline description 'foogoo': unknown pass name 'foogoo'
34 ; ERR: LLVM ERROR: unable to parse pass pipeline description: foogoo
3535
3636 ; RUN: not llvm-lto2 run %t1.bc -o %t.o \
3737 ; RUN: -r %t1.bc,patatino,px -aa-pipeline patatino \
3838 ; RUN: -opt-pipeline loweratomic 2>&1 | \
3939 ; RUN: FileCheck %s --check-prefix=AAERR
4040
41 ; AAERR: LLVM ERROR: unable to parse AA pipeline description 'patatino': unknown alias analysis name 'patatino'
41 ; AAERR: LLVM ERROR: unable to parse AA pipeline description: patatino
1212
1313 ; Don't start with incorrect passes specified
1414 ; RUN: not llvm-opt-fuzzer %t -ignore_remaining_args=1 -mtriple x86_64 -passes no-pass 2>&1 | FileCheck -check-prefix=PIPELINE %s
15 ; PIPELINE: unknown pass name 'no-pass'
15 ; PIPELINE: can't parse pass pipeline
1616
1717 ; Correct command line
1818 ; RUN: llvm-opt-fuzzer %t -ignore_remaining_args=1 -mtriple x86_64 -passes instcombine 2>&1 | FileCheck -check-prefix=CORRECT %s
143143 PB.registerLoopAnalyses(LAM);
144144 PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
145145
146 auto Err = PB.parsePassPipeline(MPM, PassPipeline, false, false);
147 assert(!Err && "Should have been checked during fuzzer initialization");
148 // Only fail with assert above, otherwise ignore the parsing error.
149 consumeError(std::move(Err));
146 bool Ok = PB.parsePassPipeline(MPM, PassPipeline, false, false);
147 assert(Ok && "Should have been checked during fuzzer initialization");
148 (void)Ok; // silence unused variable warning on release builds
150149
151150 // Run passes which we need to test
152151 //
235234
236235 PassBuilder PB(TM.get());
237236 ModulePassManager MPM;
238 if (auto Err = PB.parsePassPipeline(MPM, PassPipeline, false, false)) {
239 errs() << *argv[0] << ": " << toString(std::move(Err)) << "\n";
237 if (!PB.parsePassPipeline(MPM, PassPipeline, false, false)) {
238 errs() << *argv[0] << ": can't parse pass pipeline\n";
240239 exit(1);
241240 }
242241
123123
124124 // Verify the pipeline is parseable:
125125 PassManagerT PM;
126 if (auto Err = PB.parsePassPipeline(PM, PipelineText)) {
127 errs() << "Could not parse pipeline '" << PipelineText
128 << "'. I'm going to ignore it.\n";
129 return false;
130 }
131 return true;
126 if (PB.parsePassPipeline(PM, PipelineText))
127 return true;
128
129 errs() << "Could not parse pipeline '" << PipelineText
130 << "'. I'm going to igore it.\n";
131 return false;
132132 }
133133
134134 /// If one of the EPPipeline command line options was given, register callbacks
136136 static void registerEPCallbacks(PassBuilder &PB, bool VerifyEachPass,
137137 bool DebugLogging) {
138138 if (tryParsePipelineText(PB, PeepholeEPPipeline))
139 PB.registerPeepholeEPCallback(
140 [&PB, VerifyEachPass, DebugLogging](
141 FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
142 ExitOnError Err("Unable to parse PeepholeEP pipeline: ");
143 Err(PB.parsePassPipeline(PM, PeepholeEPPipeline, VerifyEachPass,
144 DebugLogging));
145 });
139 PB.registerPeepholeEPCallback([&PB, VerifyEachPass, DebugLogging](
140 FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
141 PB.parsePassPipeline(PM, PeepholeEPPipeline, VerifyEachPass,
142 DebugLogging);
143 });
146144 if (tryParsePipelineText(PB,
147145 LateLoopOptimizationsEPPipeline))
148146 PB.registerLateLoopOptimizationsEPCallback(
149147 [&PB, VerifyEachPass, DebugLogging](
150148 LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
151 ExitOnError Err("Unable to parse LateLoopOptimizationsEP pipeline: ");
152 Err(PB.parsePassPipeline(PM, LateLoopOptimizationsEPPipeline,
153 VerifyEachPass, DebugLogging));
149 PB.parsePassPipeline(PM, LateLoopOptimizationsEPPipeline,
150 VerifyEachPass, DebugLogging);
154151 });
155152 if (tryParsePipelineText(PB, LoopOptimizerEndEPPipeline))
156 PB.registerLoopOptimizerEndEPCallback(
157 [&PB, VerifyEachPass, DebugLogging](
158 LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
159 ExitOnError Err("Unable to parse LoopOptimizerEndEP pipeline: ");
160 Err(PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline,
161 VerifyEachPass, DebugLogging));
162 });
153 PB.registerLoopOptimizerEndEPCallback([&PB, VerifyEachPass, DebugLogging](
154 LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
155 PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline, VerifyEachPass,
156 DebugLogging);
157 });
163158 if (tryParsePipelineText(PB,
164159 ScalarOptimizerLateEPPipeline))
165160 PB.registerScalarOptimizerLateEPCallback(
166161 [&PB, VerifyEachPass, DebugLogging](
167162 FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
168 ExitOnError Err("Unable to parse ScalarOptimizerLateEP pipeline: ");
169 Err(PB.parsePassPipeline(PM, ScalarOptimizerLateEPPipeline,
170 VerifyEachPass, DebugLogging));
163 PB.parsePassPipeline(PM, ScalarOptimizerLateEPPipeline,
164 VerifyEachPass, DebugLogging);
171165 });
172166 if (tryParsePipelineText(PB, CGSCCOptimizerLateEPPipeline))
173 PB.registerCGSCCOptimizerLateEPCallback(
174 [&PB, VerifyEachPass, DebugLogging](
175 CGSCCPassManager &PM, PassBuilder::OptimizationLevel Level) {
176 ExitOnError Err("Unable to parse CGSCCOptimizerLateEP pipeline: ");
177 Err(PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline,
178 VerifyEachPass, DebugLogging));
179 });
167 PB.registerCGSCCOptimizerLateEPCallback([&PB, VerifyEachPass, DebugLogging](
168 CGSCCPassManager &PM, PassBuilder::OptimizationLevel Level) {
169 PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline, VerifyEachPass,
170 DebugLogging);
171 });
180172 if (tryParsePipelineText(PB, VectorizerStartEPPipeline))
181 PB.registerVectorizerStartEPCallback(
182 [&PB, VerifyEachPass, DebugLogging](
183 FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
184 ExitOnError Err("Unable to parse VectorizerStartEP pipeline: ");
185 Err(PB.parsePassPipeline(PM, VectorizerStartEPPipeline,
186 VerifyEachPass, DebugLogging));
187 });
173 PB.registerVectorizerStartEPCallback([&PB, VerifyEachPass, DebugLogging](
174 FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
175 PB.parsePassPipeline(PM, VectorizerStartEPPipeline, VerifyEachPass,
176 DebugLogging);
177 });
188178 if (tryParsePipelineText(PB, PipelineStartEPPipeline))
189179 PB.registerPipelineStartEPCallback(
190180 [&PB, VerifyEachPass, DebugLogging](ModulePassManager &PM) {
191 ExitOnError Err("Unable to parse PipelineStartEP pipeline: ");
192 Err(PB.parsePassPipeline(PM, PipelineStartEPPipeline, VerifyEachPass,
193 DebugLogging));
181 PB.parsePassPipeline(PM, PipelineStartEPPipeline, VerifyEachPass,
182 DebugLogging);
194183 });
195184 }
196185
268257 // Specially handle the alias analysis manager so that we can register
269258 // a custom pipeline of AA passes with it.
270259 AAManager AA;
271 if (auto Err = PB.parseAAPipeline(AA, AAPipeline)) {
272 errs() << Arg0 << ": " << toString(std::move(Err)) << "\n";
260 if (!PB.parseAAPipeline(AA, AAPipeline)) {
261 errs() << Arg0 << ": unable to parse AA pipeline description.\n";
273262 return false;
274263 }
275264
294283 if (EnableDebugify)
295284 MPM.addPass(NewPMDebugifyPass());
296285
297 if (auto Err =
298 PB.parsePassPipeline(MPM, PassPipeline, VerifyEachPass, DebugPM)) {
299 errs() << Arg0 << ": " << toString(std::move(Err)) << "\n";
286 if (!PB.parsePassPipeline(MPM, PassPipeline, VerifyEachPass, DebugPM)) {
287 errs() << Arg0 << ": unable to parse pass pipeline description.\n";
300288 return false;
301289 }
302290
3939 VerifierTest.cpp
4040 WaymarkTest.cpp
4141 )
42
43 target_link_libraries(IRTests PRIVATE LLVMTestingSupport)
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "llvm/Testing/Support/Error.h"
109 #include
1110 #include
1211 #include
460459 .WillOnce(Invoke(getAnalysisResult));
461460
462461 StringRef PipelineText = "test-transform";
463 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
462 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
464463 << "Pipeline was: " << PipelineText;
465464
466465 PM.run(*M, AM);
494493 .InSequence(PISequence);
495494
496495 StringRef PipelineText = "test-transform";
497 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
496 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
498497 << "Pipeline was: " << PipelineText;
499498
500499 PM.run(*M, AM);
525524 .Times(0);
526525
527526 StringRef PipelineText = "test-transform";
528 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
527 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
529528 << "Pipeline was: " << PipelineText;
530529
531530 PM.run(*M, AM);
537536 .WillOnce(Invoke(getAnalysisResult));
538537
539538 StringRef PipelineText = "test-transform";
540 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
539 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
541540 << "Pipeline was: " << PipelineText;
542541 PM.run(*M, AM);
543542 }
571570 .InSequence(PISequence);
572571
573572 StringRef PipelineText = "test-transform";
574 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
573 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
575574 << "Pipeline was: " << PipelineText;
576575 PM.run(*M, AM);
577576 }
604603 .Times(0);
605604
606605 StringRef PipelineText = "test-transform";
607 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
606 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
608607 << "Pipeline was: " << PipelineText;
609608 PM.run(*M, AM);
610609 }
615614 .WillOnce(WithArgs<0, 1, 2>(Invoke(getAnalysisResult)));
616615
617616 StringRef PipelineText = "test-transform";
618 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
617 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
619618 << "Pipeline was: " << PipelineText;
620619 PM.run(*M, AM);
621620 }
650649 .InSequence(PISequence);
651650
652651 StringRef PipelineText = "test-transform";
653 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
652 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
654653 << "Pipeline was: " << PipelineText;
655654 PM.run(*M, AM);
656655 }
682681 .Times(0);
683682
684683 StringRef PipelineText = "test-transform";
685 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
684 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
686685 << "Pipeline was: " << PipelineText;
687686 PM.run(*M, AM);
688687 }
693692 .WillOnce(WithArgs<0, 1, 2>(Invoke(getAnalysisResult)));
694693
695694 StringRef PipelineText = "test-transform";
696 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
695 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
697696 << "Pipeline was: " << PipelineText;
698697 PM.run(*M, AM);
699698 }
727726 .InSequence(PISequence);
728727
729728 StringRef PipelineText = "test-transform";
730 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
729 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
731730 << "Pipeline was: " << PipelineText;
732731 PM.run(*M, AM);
733732 }
759758 .Times(0);
760759
761760 StringRef PipelineText = "test-transform";
762 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
761 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
763762 << "Pipeline was: " << PipelineText;
764763 PM.run(*M, AM);
765764 }
774773 EXPECT_CALL(AnalysisHandle, invalidate(HasName(""), _, _));
775774
776775 StringRef PipelineText = "require,invalidate";
777 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
776 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
778777 << "Pipeline was: " << PipelineText;
779778 PM.run(*M, AM);
780779 }
784783 EXPECT_CALL(AnalysisHandle, invalidate(HasName("(foo)"), _, _));
785784
786785 StringRef PipelineText = "require,invalidate";
787 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
786 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
788787 << "Pipeline was: " << PipelineText;
789788 PM.run(*M, AM);
790789 }
794793 EXPECT_CALL(AnalysisHandle, invalidate(HasName("foo"), _, _));
795794
796795 StringRef PipelineText = "require,invalidate";
797 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
796 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
798797 << "Pipeline was: " << PipelineText;
799798 PM.run(*M, AM);
800799 }
805804
806805 StringRef PipelineText = "require,invalidate";
807806
808 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
807 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
809808 << "Pipeline was: " << PipelineText;
810809 PM.run(*M, AM);
811810 }
845844
846845 StringRef PipelineText =
847846 "another-pipeline(test-transform,invalidate)";
848 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
847 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
849848 << "Pipeline was: " << PipelineText;
850849 PM.run(*M, AM);
851850
852851 /// Test the negative case
853852 PipelineText = "another-pipeline(instcombine)";
854 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Failed())
853 ASSERT_FALSE(PB.parsePassPipeline(PM, PipelineText, true))
855854 << "Pipeline was: " << PipelineText;
856855 }
857856 } // end anonymous namespace
1111 PluginsTest.cpp
1212 )
1313 export_executable_symbols(PluginsTests)
14 target_link_libraries(PluginsTests PRIVATE LLVMTestingSupport)
1514
1615 set(LLVM_LINK_COMPONENTS)
1716 add_llvm_loadable_module(TestPlugin
1414 #include "llvm/Support/FileSystem.h"
1515 #include "llvm/Support/ManagedStatic.h"
1616 #include "llvm/Support/Path.h"
17 #include "llvm/Testing/Support/Error.h"
1817 #include "llvm/Transforms/Scalar/LoopPassManager.h"
1918 #include "gtest/gtest.h"
2019
5453
5554 PassBuilder PB;
5655 ModulePassManager PM;
57 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, "plugin-pass"), Failed());
56 ASSERT_FALSE(PB.parsePassPipeline(PM, "plugin-pass"));
5857
5958 Plugin->registerPassBuilderCallbacks(PB);
60 ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, "plugin-pass"), Succeeded());
59 ASSERT_TRUE(PB.parsePassPipeline(PM, "plugin-pass"));
6160 }