diff options
| author | Fedor Sergeev <fedor.sergeev@azul.com> | 2018-10-15 15:36:08 +0000 |
|---|---|---|
| committer | Fedor Sergeev <fedor.sergeev@azul.com> | 2018-10-15 15:36:08 +0000 |
| commit | a01be0f217712a9b8a4df2d48fd420e4c786a569 (patch) | |
| tree | 368caea9719291f8f0146d5a2f6acf604512e9fe /llvm | |
| parent | b06ac18ee9d5e8341d9268c4e59c9143e349692d (diff) | |
| download | bcm5719-llvm-a01be0f217712a9b8a4df2d48fd420e4c786a569.tar.gz bcm5719-llvm-a01be0f217712a9b8a4df2d48fd420e4c786a569.zip | |
Revert "[NewPM] teach -passes= to emit meaningful error messages"
This reverts r344519 due to failures in pipeline-parsing test.
llvm-svn: 344524
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/Passes/PassBuilder.h | 51 | ||||
| -rw-r--r-- | llvm/lib/LTO/LTOBackend.cpp | 14 | ||||
| -rw-r--r-- | llvm/lib/Passes/PassBuilder.cpp | 366 | ||||
| -rw-r--r-- | llvm/test/Other/pass-pipeline-parsing.ll | 83 | ||||
| -rw-r--r-- | llvm/test/tools/llvm-lto2/X86/pipeline.ll | 4 | ||||
| -rw-r--r-- | llvm/test/tools/llvm-opt-fuzzer/command-line.ll | 2 | ||||
| -rw-r--r-- | llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp | 11 | ||||
| -rw-r--r-- | llvm/tools/opt/NewPMDriver.cpp | 84 | ||||
| -rw-r--r-- | llvm/unittests/IR/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | llvm/unittests/IR/PassBuilderCallbacksTest.cpp | 37 | ||||
| -rw-r--r-- | llvm/unittests/Passes/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | llvm/unittests/Passes/PluginsTest.cpp | 5 |
12 files changed, 266 insertions, 394 deletions
diff --git a/llvm/include/llvm/Passes/PassBuilder.h b/llvm/include/llvm/Passes/PassBuilder.h index 22e5eb0caa0..91314430a96 100644 --- a/llvm/include/llvm/Passes/PassBuilder.h +++ b/llvm/include/llvm/Passes/PassBuilder.h @@ -19,7 +19,6 @@ #include "llvm/ADT/Optional.h" #include "llvm/Analysis/CGSCCPassManager.h" #include "llvm/IR/PassManager.h" -#include "llvm/Support/Error.h" #include "llvm/Transforms/Instrumentation.h" #include "llvm/Transforms/Scalar/LoopPassManager.h" #include <vector> @@ -385,9 +384,8 @@ public: /// If the sequence of passes aren't all the exact same kind of pass, it will /// be an error. You cannot mix different levels implicitly, you must /// explicitly form a pass manager in which to nest passes. - Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText, - bool VerifyEachPass = true, - bool DebugLogging = false); + bool parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText, + bool VerifyEachPass = true, bool DebugLogging = false); /// {{@ Parse a textual pass pipeline description into a specific PassManager /// @@ -396,15 +394,12 @@ public: /// this is the valid pipeline text: /// /// function(lpass) - Error parsePassPipeline(CGSCCPassManager &CGPM, StringRef PipelineText, - bool VerifyEachPass = true, - bool DebugLogging = false); - Error parsePassPipeline(FunctionPassManager &FPM, StringRef PipelineText, - bool VerifyEachPass = true, - bool DebugLogging = false); - Error parsePassPipeline(LoopPassManager &LPM, StringRef PipelineText, - bool VerifyEachPass = true, - bool DebugLogging = false); + bool parsePassPipeline(CGSCCPassManager &CGPM, StringRef PipelineText, + bool VerifyEachPass = true, bool DebugLogging = false); + bool parsePassPipeline(FunctionPassManager &FPM, StringRef PipelineText, + bool VerifyEachPass = true, bool DebugLogging = false); + bool parsePassPipeline(LoopPassManager &LPM, StringRef PipelineText, + bool VerifyEachPass = true, bool DebugLogging = false); /// @}} /// Parse a textual alias analysis pipeline into the provided AA manager. @@ -422,7 +417,7 @@ public: /// Returns false if the text cannot be parsed cleanly. The specific state of /// the \p AA manager is unspecified if such an error is encountered and this /// returns false. - Error parseAAPipeline(AAManager &AA, StringRef PipelineText); + bool parseAAPipeline(AAManager &AA, StringRef PipelineText); /// Register a callback for a default optimizer pipeline extension /// point @@ -570,28 +565,28 @@ private: static Optional<std::vector<PipelineElement>> parsePipelineText(StringRef Text); - Error parseModulePass(ModulePassManager &MPM, const PipelineElement &E, - bool VerifyEachPass, bool DebugLogging); - Error parseCGSCCPass(CGSCCPassManager &CGPM, const PipelineElement &E, + bool parseModulePass(ModulePassManager &MPM, const PipelineElement &E, bool VerifyEachPass, bool DebugLogging); - Error parseFunctionPass(FunctionPassManager &FPM, const PipelineElement &E, - bool VerifyEachPass, bool DebugLogging); - Error parseLoopPass(LoopPassManager &LPM, const PipelineElement &E, + bool parseCGSCCPass(CGSCCPassManager &CGPM, const PipelineElement &E, bool VerifyEachPass, bool DebugLogging); + bool parseFunctionPass(FunctionPassManager &FPM, const PipelineElement &E, + bool VerifyEachPass, bool DebugLogging); + bool parseLoopPass(LoopPassManager &LPM, const PipelineElement &E, + bool VerifyEachPass, bool DebugLogging); bool parseAAPassName(AAManager &AA, StringRef Name); - Error parseLoopPassPipeline(LoopPassManager &LPM, + bool parseLoopPassPipeline(LoopPassManager &LPM, + ArrayRef<PipelineElement> Pipeline, + bool VerifyEachPass, bool DebugLogging); + bool parseFunctionPassPipeline(FunctionPassManager &FPM, + ArrayRef<PipelineElement> Pipeline, + bool VerifyEachPass, bool DebugLogging); + bool parseCGSCCPassPipeline(CGSCCPassManager &CGPM, ArrayRef<PipelineElement> Pipeline, bool VerifyEachPass, bool DebugLogging); - Error parseFunctionPassPipeline(FunctionPassManager &FPM, - ArrayRef<PipelineElement> Pipeline, - bool VerifyEachPass, bool DebugLogging); - Error parseCGSCCPassPipeline(CGSCCPassManager &CGPM, + bool parseModulePassPipeline(ModulePassManager &MPM, ArrayRef<PipelineElement> Pipeline, bool VerifyEachPass, bool DebugLogging); - Error parseModulePassPipeline(ModulePassManager &MPM, - ArrayRef<PipelineElement> Pipeline, - bool VerifyEachPass, bool DebugLogging); void addPGOInstrPasses(ModulePassManager &MPM, bool DebugLogging, OptimizationLevel Level, bool RunProfileGen, diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index 1f9d60a5bdf..20fc40de4b9 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -162,7 +162,7 @@ static void runNewPMPasses(Config &Conf, Module &Mod, TargetMachine *TM, AAManager AA; // Parse a custom AA pipeline if asked to. - if (auto Err = PB.parseAAPipeline(AA, "default")) + if (!PB.parseAAPipeline(AA, "default")) report_fatal_error("Error parsing default AA pipeline"); LoopAnalysisManager LAM(Conf.DebugPassManager); @@ -221,9 +221,9 @@ static void runNewPMCustomPasses(Module &Mod, TargetMachine *TM, // Parse a custom AA pipeline if asked to. if (!AAPipelineDesc.empty()) - if (auto Err = PB.parseAAPipeline(AA, AAPipelineDesc)) - report_fatal_error("unable to parse AA pipeline description '" + - AAPipelineDesc + "': " + toString(std::move(Err))); + if (!PB.parseAAPipeline(AA, AAPipelineDesc)) + report_fatal_error("unable to parse AA pipeline description: " + + AAPipelineDesc); LoopAnalysisManager LAM; FunctionAnalysisManager FAM; @@ -246,9 +246,9 @@ static void runNewPMCustomPasses(Module &Mod, TargetMachine *TM, MPM.addPass(VerifierPass()); // Now, add all the passes we've been requested to. - if (auto Err = PB.parsePassPipeline(MPM, PipelineDesc)) - report_fatal_error("unable to parse pass pipeline description '" + - PipelineDesc + "': " + toString(std::move(Err))); + if (!PB.parsePassPipeline(MPM, PipelineDesc)) + report_fatal_error("unable to parse pass pipeline description: " + + PipelineDesc); if (!DisableVerify) MPM.addPass(VerifierPass()); diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index f6313d23e2d..09758dc5651 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -58,7 +58,6 @@ #include "llvm/IR/PassManager.h" #include "llvm/IR/Verifier.h" #include "llvm/Support/Debug.h" -#include "llvm/Support/FormatVariadic.h" #include "llvm/Support/Regex.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h" @@ -1403,9 +1402,9 @@ PassBuilder::parsePipelineText(StringRef Text) { return {std::move(ResultPipeline)}; } -Error PassBuilder::parseModulePass(ModulePassManager &MPM, - const PipelineElement &E, - bool VerifyEachPass, bool DebugLogging) { +bool PassBuilder::parseModulePass(ModulePassManager &MPM, + const PipelineElement &E, bool VerifyEachPass, + bool DebugLogging) { auto &Name = E.Name; auto &InnerPipeline = E.InnerPipeline; @@ -1413,56 +1412,50 @@ Error PassBuilder::parseModulePass(ModulePassManager &MPM, if (!InnerPipeline.empty()) { if (Name == "module") { ModulePassManager NestedMPM(DebugLogging); - if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline, - VerifyEachPass, DebugLogging)) - return Err; + if (!parseModulePassPipeline(NestedMPM, InnerPipeline, VerifyEachPass, + DebugLogging)) + return false; MPM.addPass(std::move(NestedMPM)); - return Error::success(); + return true; } if (Name == "cgscc") { CGSCCPassManager CGPM(DebugLogging); - if (auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline, VerifyEachPass, - DebugLogging)) - return Err; + if (!parseCGSCCPassPipeline(CGPM, InnerPipeline, VerifyEachPass, + DebugLogging)) + return false; MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM))); - return Error::success(); + return true; } if (Name == "function") { FunctionPassManager FPM(DebugLogging); - if (auto Err = parseFunctionPassPipeline(FPM, InnerPipeline, - VerifyEachPass, DebugLogging)) - return Err; + if (!parseFunctionPassPipeline(FPM, InnerPipeline, VerifyEachPass, + DebugLogging)) + return false; MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM))); - return Error::success(); + return true; } if (auto Count = parseRepeatPassName(Name)) { ModulePassManager NestedMPM(DebugLogging); - if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline, - VerifyEachPass, DebugLogging)) - return Err; + if (!parseModulePassPipeline(NestedMPM, InnerPipeline, VerifyEachPass, + DebugLogging)) + return false; MPM.addPass(createRepeatedPass(*Count, std::move(NestedMPM))); - return Error::success(); + return true; } for (auto &C : ModulePipelineParsingCallbacks) if (C(Name, MPM, InnerPipeline)) - return Error::success(); + return true; // Normal passes can't have pipelines. - return make_error<StringError>( - formatv("invalid use of '{0}' pass as module pipeline", Name).str(), - inconvertibleErrorCode()); - ; + return false; } // Manually handle aliases for pre-configured pipeline fragments. if (startsWithDefaultPipelineAliasPrefix(Name)) { SmallVector<StringRef, 3> Matches; if (!DefaultAliasRegex.match(Name, &Matches)) - return make_error<StringError>( - formatv("unknown default pipeline alias '{0}'", Name).str(), - inconvertibleErrorCode()); - + return false; assert(Matches.size() == 3 && "Must capture two matched strings!"); OptimizationLevel L = StringSwitch<OptimizationLevel>(Matches[2]) @@ -1474,7 +1467,7 @@ Error PassBuilder::parseModulePass(ModulePassManager &MPM, .Case("Oz", Oz); if (L == O0) // At O0 we do nothing at all! - return Error::success(); + return true; if (Matches[1] == "default") { MPM.addPass(buildPerModuleDefaultPipeline(L, DebugLogging)); @@ -1488,40 +1481,38 @@ Error PassBuilder::parseModulePass(ModulePassManager &MPM, assert(Matches[1] == "lto" && "Not one of the matched options!"); MPM.addPass(buildLTODefaultPipeline(L, DebugLogging, nullptr)); } - return Error::success(); + return true; } // Finally expand the basic registered passes from the .inc file. #define MODULE_PASS(NAME, CREATE_PASS) \ if (Name == NAME) { \ MPM.addPass(CREATE_PASS); \ - return Error::success(); \ + return true; \ } #define MODULE_ANALYSIS(NAME, CREATE_PASS) \ if (Name == "require<" NAME ">") { \ MPM.addPass( \ RequireAnalysisPass< \ std::remove_reference<decltype(CREATE_PASS)>::type, Module>()); \ - return Error::success(); \ + return true; \ } \ if (Name == "invalidate<" NAME ">") { \ MPM.addPass(InvalidateAnalysisPass< \ std::remove_reference<decltype(CREATE_PASS)>::type>()); \ - return Error::success(); \ + return true; \ } #include "PassRegistry.def" for (auto &C : ModulePipelineParsingCallbacks) if (C(Name, MPM, InnerPipeline)) - return Error::success(); - return make_error<StringError>( - formatv("unknown module pass '{0}'", Name).str(), - inconvertibleErrorCode()); + return true; + return false; } -Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM, - const PipelineElement &E, bool VerifyEachPass, - bool DebugLogging) { +bool PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM, + const PipelineElement &E, bool VerifyEachPass, + bool DebugLogging) { auto &Name = E.Name; auto &InnerPipeline = E.InnerPipeline; @@ -1529,55 +1520,53 @@ Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM, if (!InnerPipeline.empty()) { if (Name == "cgscc") { CGSCCPassManager NestedCGPM(DebugLogging); - if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, - VerifyEachPass, DebugLogging)) - return Err; + if (!parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, VerifyEachPass, + DebugLogging)) + return false; // Add the nested pass manager with the appropriate adaptor. CGPM.addPass(std::move(NestedCGPM)); - return Error::success(); + return true; } if (Name == "function") { FunctionPassManager FPM(DebugLogging); - if (auto Err = parseFunctionPassPipeline(FPM, InnerPipeline, - VerifyEachPass, DebugLogging)) - return Err; + if (!parseFunctionPassPipeline(FPM, InnerPipeline, VerifyEachPass, + DebugLogging)) + return false; // Add the nested pass manager with the appropriate adaptor. CGPM.addPass(createCGSCCToFunctionPassAdaptor(std::move(FPM))); - return Error::success(); + return true; } if (auto Count = parseRepeatPassName(Name)) { CGSCCPassManager NestedCGPM(DebugLogging); - if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, - VerifyEachPass, DebugLogging)) - return Err; + if (!parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, VerifyEachPass, + DebugLogging)) + return false; CGPM.addPass(createRepeatedPass(*Count, std::move(NestedCGPM))); - return Error::success(); + return true; } if (auto MaxRepetitions = parseDevirtPassName(Name)) { CGSCCPassManager NestedCGPM(DebugLogging); - if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, - VerifyEachPass, DebugLogging)) - return Err; + if (!parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, VerifyEachPass, + DebugLogging)) + return false; CGPM.addPass( createDevirtSCCRepeatedPass(std::move(NestedCGPM), *MaxRepetitions)); - return Error::success(); + return true; } for (auto &C : CGSCCPipelineParsingCallbacks) if (C(Name, CGPM, InnerPipeline)) - return Error::success(); + return true; // Normal passes can't have pipelines. - return make_error<StringError>( - formatv("invalid use of '{0}' pass as cgscc pipeline", Name).str(), - inconvertibleErrorCode()); + return false; } // Now expand the basic registered passes from the .inc file. #define CGSCC_PASS(NAME, CREATE_PASS) \ if (Name == NAME) { \ CGPM.addPass(CREATE_PASS); \ - return Error::success(); \ + return true; \ } #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \ if (Name == "require<" NAME ">") { \ @@ -1585,26 +1574,24 @@ Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM, std::remove_reference<decltype(CREATE_PASS)>::type, \ LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \ CGSCCUpdateResult &>()); \ - return Error::success(); \ + return true; \ } \ if (Name == "invalidate<" NAME ">") { \ CGPM.addPass(InvalidateAnalysisPass< \ std::remove_reference<decltype(CREATE_PASS)>::type>()); \ - return Error::success(); \ + return true; \ } #include "PassRegistry.def" for (auto &C : CGSCCPipelineParsingCallbacks) if (C(Name, CGPM, InnerPipeline)) - return Error::success(); - return make_error<StringError>( - formatv("unknown cgscc pass '{0}'", Name).str(), - inconvertibleErrorCode()); + return true; + return false; } -Error PassBuilder::parseFunctionPass(FunctionPassManager &FPM, - const PipelineElement &E, - bool VerifyEachPass, bool DebugLogging) { +bool PassBuilder::parseFunctionPass(FunctionPassManager &FPM, + const PipelineElement &E, + bool VerifyEachPass, bool DebugLogging) { auto &Name = E.Name; auto &InnerPipeline = E.InnerPipeline; @@ -1612,72 +1599,68 @@ Error PassBuilder::parseFunctionPass(FunctionPassManager &FPM, if (!InnerPipeline.empty()) { if (Name == "function") { FunctionPassManager NestedFPM(DebugLogging); - if (auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline, - VerifyEachPass, DebugLogging)) - return Err; + if (!parseFunctionPassPipeline(NestedFPM, InnerPipeline, VerifyEachPass, + DebugLogging)) + return false; // Add the nested pass manager with the appropriate adaptor. FPM.addPass(std::move(NestedFPM)); - return Error::success(); + return true; } if (Name == "loop") { LoopPassManager LPM(DebugLogging); - if (auto Err = parseLoopPassPipeline(LPM, InnerPipeline, VerifyEachPass, - DebugLogging)) - return Err; + if (!parseLoopPassPipeline(LPM, InnerPipeline, VerifyEachPass, + DebugLogging)) + return false; // Add the nested pass manager with the appropriate adaptor. FPM.addPass( createFunctionToLoopPassAdaptor(std::move(LPM), DebugLogging)); - return Error::success(); + return true; } if (auto Count = parseRepeatPassName(Name)) { FunctionPassManager NestedFPM(DebugLogging); - if (auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline, - VerifyEachPass, DebugLogging)) - return Err; + if (!parseFunctionPassPipeline(NestedFPM, InnerPipeline, VerifyEachPass, + DebugLogging)) + return false; FPM.addPass(createRepeatedPass(*Count, std::move(NestedFPM))); - return Error::success(); + return true; } for (auto &C : FunctionPipelineParsingCallbacks) if (C(Name, FPM, InnerPipeline)) - return Error::success(); + return true; // Normal passes can't have pipelines. - return make_error<StringError>( - formatv("invalid use of '{0}' pass as function pipeline", Name).str(), - inconvertibleErrorCode()); + return false; } // Now expand the basic registered passes from the .inc file. #define FUNCTION_PASS(NAME, CREATE_PASS) \ if (Name == NAME) { \ FPM.addPass(CREATE_PASS); \ - return Error::success(); \ + return true; \ } #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \ if (Name == "require<" NAME ">") { \ FPM.addPass( \ RequireAnalysisPass< \ std::remove_reference<decltype(CREATE_PASS)>::type, Function>()); \ - return Error::success(); \ + return true; \ } \ if (Name == "invalidate<" NAME ">") { \ FPM.addPass(InvalidateAnalysisPass< \ std::remove_reference<decltype(CREATE_PASS)>::type>()); \ - return Error::success(); \ + return true; \ } #include "PassRegistry.def" for (auto &C : FunctionPipelineParsingCallbacks) if (C(Name, FPM, InnerPipeline)) - return Error::success(); - return make_error<StringError>( - formatv("unknown function pass '{0}'", Name).str(), - inconvertibleErrorCode()); + return true; + return false; } -Error PassBuilder::parseLoopPass(LoopPassManager &LPM, const PipelineElement &E, - bool VerifyEachPass, bool DebugLogging) { +bool PassBuilder::parseLoopPass(LoopPassManager &LPM, const PipelineElement &E, + bool VerifyEachPass, bool DebugLogging) { StringRef Name = E.Name; auto &InnerPipeline = E.InnerPipeline; @@ -1685,37 +1668,35 @@ Error PassBuilder::parseLoopPass(LoopPassManager &LPM, const PipelineElement &E, if (!InnerPipeline.empty()) { if (Name == "loop") { LoopPassManager NestedLPM(DebugLogging); - if (auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline, - VerifyEachPass, DebugLogging)) - return Err; + if (!parseLoopPassPipeline(NestedLPM, InnerPipeline, VerifyEachPass, + DebugLogging)) + return false; // Add the nested pass manager with the appropriate adaptor. LPM.addPass(std::move(NestedLPM)); - return Error::success(); + return true; } if (auto Count = parseRepeatPassName(Name)) { LoopPassManager NestedLPM(DebugLogging); - if (auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline, - VerifyEachPass, DebugLogging)) - return Err; + if (!parseLoopPassPipeline(NestedLPM, InnerPipeline, VerifyEachPass, + DebugLogging)) + return false; LPM.addPass(createRepeatedPass(*Count, std::move(NestedLPM))); - return Error::success(); + return true; } for (auto &C : LoopPipelineParsingCallbacks) if (C(Name, LPM, InnerPipeline)) - return Error::success(); + return true; // Normal passes can't have pipelines. - return make_error<StringError>( - formatv("invalid use of '{0}' pass as loop pipeline", Name).str(), - inconvertibleErrorCode()); + return false; } // Now expand the basic registered passes from the .inc file. #define LOOP_PASS(NAME, CREATE_PASS) \ if (Name == NAME) { \ LPM.addPass(CREATE_PASS); \ - return Error::success(); \ + return true; \ } #define LOOP_ANALYSIS(NAME, CREATE_PASS) \ if (Name == "require<" NAME ">") { \ @@ -1723,20 +1704,19 @@ Error PassBuilder::parseLoopPass(LoopPassManager &LPM, const PipelineElement &E, std::remove_reference<decltype(CREATE_PASS)>::type, Loop, \ LoopAnalysisManager, LoopStandardAnalysisResults &, \ LPMUpdater &>()); \ - return Error::success(); \ + return true; \ } \ if (Name == "invalidate<" NAME ">") { \ LPM.addPass(InvalidateAnalysisPass< \ std::remove_reference<decltype(CREATE_PASS)>::type>()); \ - return Error::success(); \ + return true; \ } #include "PassRegistry.def" for (auto &C : LoopPipelineParsingCallbacks) if (C(Name, LPM, InnerPipeline)) - return Error::success(); - return make_error<StringError>(formatv("unknown loop pass '{0}'", Name).str(), - inconvertibleErrorCode()); + return true; + return false; } bool PassBuilder::parseAAPassName(AAManager &AA, StringRef Name) { @@ -1760,42 +1740,41 @@ bool PassBuilder::parseAAPassName(AAManager &AA, StringRef Name) { return false; } -Error PassBuilder::parseLoopPassPipeline(LoopPassManager &LPM, - ArrayRef<PipelineElement> Pipeline, - bool VerifyEachPass, - bool DebugLogging) { +bool PassBuilder::parseLoopPassPipeline(LoopPassManager &LPM, + ArrayRef<PipelineElement> Pipeline, + bool VerifyEachPass, + bool DebugLogging) { for (const auto &Element : Pipeline) { - if (auto Err = parseLoopPass(LPM, Element, VerifyEachPass, DebugLogging)) - return Err; + if (!parseLoopPass(LPM, Element, VerifyEachPass, DebugLogging)) + return false; // FIXME: No verifier support for Loop passes! } - return Error::success(); + return true; } -Error PassBuilder::parseFunctionPassPipeline(FunctionPassManager &FPM, - ArrayRef<PipelineElement> Pipeline, - bool VerifyEachPass, - bool DebugLogging) { +bool PassBuilder::parseFunctionPassPipeline(FunctionPassManager &FPM, + ArrayRef<PipelineElement> Pipeline, + bool VerifyEachPass, + bool DebugLogging) { for (const auto &Element : Pipeline) { - if (auto Err = - parseFunctionPass(FPM, Element, VerifyEachPass, DebugLogging)) - return Err; + if (!parseFunctionPass(FPM, Element, VerifyEachPass, DebugLogging)) + return false; if (VerifyEachPass) FPM.addPass(VerifierPass()); } - return Error::success(); + return true; } -Error PassBuilder::parseCGSCCPassPipeline(CGSCCPassManager &CGPM, - ArrayRef<PipelineElement> Pipeline, - bool VerifyEachPass, - bool DebugLogging) { +bool PassBuilder::parseCGSCCPassPipeline(CGSCCPassManager &CGPM, + ArrayRef<PipelineElement> Pipeline, + bool VerifyEachPass, + bool DebugLogging) { for (const auto &Element : Pipeline) { - if (auto Err = parseCGSCCPass(CGPM, Element, VerifyEachPass, DebugLogging)) - return Err; + if (!parseCGSCCPass(CGPM, Element, VerifyEachPass, DebugLogging)) + return false; // FIXME: No verifier support for CGSCC passes! } - return Error::success(); + return true; } void PassBuilder::crossRegisterProxies(LoopAnalysisManager &LAM, @@ -1811,30 +1790,28 @@ void PassBuilder::crossRegisterProxies(LoopAnalysisManager &LAM, LAM.registerPass([&] { return FunctionAnalysisManagerLoopProxy(FAM); }); } -Error PassBuilder::parseModulePassPipeline(ModulePassManager &MPM, - ArrayRef<PipelineElement> Pipeline, - bool VerifyEachPass, - bool DebugLogging) { +bool PassBuilder::parseModulePassPipeline(ModulePassManager &MPM, + ArrayRef<PipelineElement> Pipeline, + bool VerifyEachPass, + bool DebugLogging) { for (const auto &Element : Pipeline) { - if (auto Err = parseModulePass(MPM, Element, VerifyEachPass, DebugLogging)) - return Err; + if (!parseModulePass(MPM, Element, VerifyEachPass, DebugLogging)) + return false; if (VerifyEachPass) MPM.addPass(VerifierPass()); } - return Error::success(); + return true; } // Primary pass pipeline description parsing routine for a \c ModulePassManager // FIXME: Should this routine accept a TargetMachine or require the caller to // pre-populate the analysis managers with target-specific stuff? -Error PassBuilder::parsePassPipeline(ModulePassManager &MPM, - StringRef PipelineText, - bool VerifyEachPass, bool DebugLogging) { +bool PassBuilder::parsePassPipeline(ModulePassManager &MPM, + StringRef PipelineText, bool VerifyEachPass, + bool DebugLogging) { auto Pipeline = parsePipelineText(PipelineText); if (!Pipeline || Pipeline->empty()) - return make_error<StringError>( - formatv("invalid pipeline '{0}'", PipelineText).str(), - inconvertibleErrorCode()); + return false; // If the first name isn't at the module layer, wrap the pipeline up // automatically. @@ -1851,106 +1828,73 @@ Error PassBuilder::parsePassPipeline(ModulePassManager &MPM, } else { for (auto &C : TopLevelPipelineParsingCallbacks) if (C(MPM, *Pipeline, VerifyEachPass, DebugLogging)) - return Error::success(); - - // Unknown pass or pipeline name! - auto &InnerPipeline = Pipeline->front().InnerPipeline; - return make_error<StringError>( - formatv("unknown {0} name '{1}'", - (InnerPipeline.empty() ? "pass" : "pipeline"), FirstName) - .str(), - inconvertibleErrorCode()); + return true; + + // Unknown pass name! + return false; } } - if (auto Err = - parseModulePassPipeline(MPM, *Pipeline, VerifyEachPass, DebugLogging)) - return Err; - return Error::success(); + return parseModulePassPipeline(MPM, *Pipeline, VerifyEachPass, DebugLogging); } // Primary pass pipeline description parsing routine for a \c CGSCCPassManager -Error PassBuilder::parsePassPipeline(CGSCCPassManager &CGPM, - StringRef PipelineText, - bool VerifyEachPass, bool DebugLogging) { +bool PassBuilder::parsePassPipeline(CGSCCPassManager &CGPM, + StringRef PipelineText, bool VerifyEachPass, + bool DebugLogging) { auto Pipeline = parsePipelineText(PipelineText); if (!Pipeline || Pipeline->empty()) - return make_error<StringError>( - formatv("invalid pipeline '{0}'", PipelineText).str(), - inconvertibleErrorCode()); + return false; StringRef FirstName = Pipeline->front().Name; if (!isCGSCCPassName(FirstName, CGSCCPipelineParsingCallbacks)) - return make_error<StringError>( - formatv("unknown cgscc pass '{0}' in pipeline '{1}'", FirstName, - PipelineText) - .str(), - inconvertibleErrorCode()); - - if (auto Err = - parseCGSCCPassPipeline(CGPM, *Pipeline, VerifyEachPass, DebugLogging)) - return Err; - return Error::success(); + return false; + + return parseCGSCCPassPipeline(CGPM, *Pipeline, VerifyEachPass, DebugLogging); } // Primary pass pipeline description parsing routine for a \c // FunctionPassManager -Error PassBuilder::parsePassPipeline(FunctionPassManager &FPM, - StringRef PipelineText, - bool VerifyEachPass, bool DebugLogging) { +bool PassBuilder::parsePassPipeline(FunctionPassManager &FPM, + StringRef PipelineText, bool VerifyEachPass, + bool DebugLogging) { auto Pipeline = parsePipelineText(PipelineText); if (!Pipeline || Pipeline->empty()) - return make_error<StringError>( - formatv("invalid pipeline '{0}'", PipelineText).str(), - inconvertibleErrorCode()); + return false; StringRef FirstName = Pipeline->front().Name; if (!isFunctionPassName(FirstName, FunctionPipelineParsingCallbacks)) - return make_error<StringError>( - formatv("unknown function pass '{0}' in pipeline '{1}'", FirstName, - PipelineText) - .str(), - inconvertibleErrorCode()); - - if (auto Err = parseFunctionPassPipeline(FPM, *Pipeline, VerifyEachPass, - DebugLogging)) - return Err; - return Error::success(); + return false; + + return parseFunctionPassPipeline(FPM, *Pipeline, VerifyEachPass, + DebugLogging); } // Primary pass pipeline description parsing routine for a \c LoopPassManager -Error PassBuilder::parsePassPipeline(LoopPassManager &CGPM, - StringRef PipelineText, - bool VerifyEachPass, bool DebugLogging) { +bool PassBuilder::parsePassPipeline(LoopPassManager &CGPM, + StringRef PipelineText, bool VerifyEachPass, + bool DebugLogging) { auto Pipeline = parsePipelineText(PipelineText); if (!Pipeline || Pipeline->empty()) - return make_error<StringError>( - formatv("invalid pipeline '{0}'", PipelineText).str(), - inconvertibleErrorCode()); - - if (auto Err = - parseLoopPassPipeline(CGPM, *Pipeline, VerifyEachPass, DebugLogging)) - return Err; + return false; - return Error::success(); + return parseLoopPassPipeline(CGPM, *Pipeline, VerifyEachPass, DebugLogging); } -Error PassBuilder::parseAAPipeline(AAManager &AA, StringRef PipelineText) { +bool PassBuilder::parseAAPipeline(AAManager &AA, StringRef PipelineText) { // If the pipeline just consists of the word 'default' just replace the AA // manager with our default one. if (PipelineText == "default") { AA = buildDefaultAAPipeline(); - return Error::success(); + return true; } while (!PipelineText.empty()) { StringRef Name; std::tie(Name, PipelineText) = PipelineText.split(','); if (!parseAAPassName(AA, Name)) - return make_error<StringError>( - formatv("unknown alias analysis name '{0}'", Name).str(), - inconvertibleErrorCode()); + return false; } - return Error::success(); + return true; } diff --git a/llvm/test/Other/pass-pipeline-parsing.ll b/llvm/test/Other/pass-pipeline-parsing.ll index d13a977dbce..b303318c796 100644 --- a/llvm/test/Other/pass-pipeline-parsing.ll +++ b/llvm/test/Other/pass-pipeline-parsing.ll @@ -54,52 +54,52 @@ ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='no-op-module)' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED1 -; CHECK-UNBALANCED1: invalid pipeline 'no-op-module)' +; CHECK-UNBALANCED1: unable to parse pass pipeline description ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='module(no-op-module))' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED2 -; CHECK-UNBALANCED2: invalid pipeline 'module(no-op-module))' +; CHECK-UNBALANCED2: unable to parse pass pipeline description ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='module(no-op-module' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED3 -; CHECK-UNBALANCED3: invalid pipeline 'module(no-op-module' +; CHECK-UNBALANCED3: unable to parse pass pipeline description ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='no-op-function)' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED4 -; CHECK-UNBALANCED4: invalid pipeline 'no-op-function)' +; CHECK-UNBALANCED4: unable to parse pass pipeline description ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='function(no-op-function))' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED5 -; CHECK-UNBALANCED5: invalid pipeline 'function(no-op-function))' +; CHECK-UNBALANCED5: unable to parse pass pipeline description ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='function(function(no-op-function)))' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED6 -; CHECK-UNBALANCED6: invalid pipeline 'function(function(no-op-function)))' +; CHECK-UNBALANCED6: unable to parse pass pipeline description ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='function(no-op-function' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED7 -; CHECK-UNBALANCED7: invalid pipeline 'function(no-op-function' +; CHECK-UNBALANCED7: unable to parse pass pipeline description ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='function(function(no-op-function)' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED8 -; CHECK-UNBALANCED8: invalid pipeline 'function(function(no-op-function)' +; CHECK-UNBALANCED8: unable to parse pass pipeline description ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='no-op-module,)' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED9 -; CHECK-UNBALANCED9: invalid pipeline 'no-op-module,)' +; CHECK-UNBALANCED9: unable to parse pass pipeline description ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='no-op-function,)' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED10 -; CHECK-UNBALANCED10: invalid pipeline 'no-op-function,)' +; CHECK-UNBALANCED10: unable to parse pass pipeline description ; RUN: opt -disable-output -debug-pass-manager \ ; RUN: -passes=no-op-cgscc,no-op-cgscc %s 2>&1 \ @@ -176,86 +176,37 @@ ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='function(no-op-function)function(no-op-function)' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-MISSING-COMMA1 -; CHECK-MISSING-COMMA1: invalid pipeline 'function(no-op-function)function(no-op-function)' +; CHECK-MISSING-COMMA1: unable to parse pass pipeline description ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='function()' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-EMPTY-INNER-PIPELINE -; CHECK-EMPTY-INNER-PIPELINE: unknown function pass '' +; CHECK-EMPTY-INNER-PIPELINE: unable to parse pass pipeline description ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='no-op-module(no-op-module,whatever)' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-PIPELINE-ON-MODULE-PASS -; CHECK-PIPELINE-ON-MODULE-PASS: invalid use of 'no-op-module' pass as module pipeline +; CHECK-PIPELINE-ON-MODULE-PASS: unable to parse pass pipeline description ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='no-op-cgscc(no-op-cgscc,whatever)' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-PIPELINE-ON-CGSCC-PASS -; CHECK-PIPELINE-ON-CGSCC-PASS: invalid use of 'no-op-cgscc' pass as cgscc pipeline +; CHECK-PIPELINE-ON-CGSCC-PASS: unable to parse pass pipeline description ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='no-op-function(no-op-function,whatever)' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-PIPELINE-ON-FUNCTION-PASS -; CHECK-PIPELINE-ON-FUNCTION-PASS: invalid use of 'no-op-function' pass as function pipeline +; CHECK-PIPELINE-ON-FUNCTION-PASS: unable to parse pass pipeline description ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='no-op-loop(no-op-loop,whatever)' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-PIPELINE-ON-LOOP-PASS -; CHECK-PIPELINE-ON-LOOP-PASS: invalid use of 'no-op-loop' pass as loop pipeline +; CHECK-PIPELINE-ON-LOOP-PASS: unable to parse pass pipeline description ; RUN: not opt -disable-output -debug-pass-manager \ ; RUN: -passes='no-op-function()' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-EMPTY-PIPELINE-ON-PASS -; CHECK-EMPTY-PIPELINE-ON-PASS: invalid use of 'no-op-function' pass as function pipeline - -; RUN: not opt -passes='no-op-module,bad' \ -; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-UNKNOWN-MODULE -; CHECK-UNKNOWN-MODULE: opt: unknown module pass 'bad' - -; RUN: not opt -passes='no-op-loop,bad' \ -; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-UNKNOWN-LOOP -; CHECK-UNKNOWN-LOOP: opt: unknown loop pass 'bad' - -; RUN: not opt -passes='no-op-cgscc,bad' \ -; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-UNKNOWN-CGSCC -; CHECK-UNKNOWN-CGSCC: opt: unknown cgscc pass 'bad' - -; RUN: not opt -passes='no-op-function,bad' \ -; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-UNKNOWN-FUNCTION -; RUN: not opt -passes='function(bad,pipeline,text)' \ -; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-UNKNOWN-FUNCTION -; RUN: not opt -passes='module(no-op-module,function(bad,pipeline,text))' \ -; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-UNKNOWN-FUNCTION -; RUN: not opt -passes='no-op-module,function(bad,pipeline,text)' \ -; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-UNKNOWN-FUNCTION -; RUN: not opt -passes='module(cgscc(function(bad,pipeline,text)))' \ -; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=CHECK-UNKNOWN-FUNCTION -; CHECK-UNKNOWN-FUNCTION: opt: unknown function pass 'bad' - -; RUN: not opt -aa-pipeline=bad -passes=no-op-function \ -; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=AA-PIPELINE-ERR -; AA-PIPELINE-ERR: unknown alias analysis name 'bad' -; RUN: opt -passes-ep-peephole=bad -passes=no-op-function \ -; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=PASSES-EP-PEEPHOLE-ERR -; PASSES-EP-PEEPHOLE-ERR: Could not parse pipeline 'bad'. I'm going to ignore it. -; RUN: opt -passes-ep-late-loop-optimizations=bad -passes=no-op-function \ -; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=PASSES-EP-LATELOOPOPT-ERR -; PASSES-EP-LATELOOPOPT-ERR: Could not parse pipeline 'bad'. I'm going to ignore it. -; RUN: opt -passes-ep-loop-optimizer-end=bad -passes=no-op-function \ -; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=PASSES-EP-LOOPOPTEND-ERR -; PASSES-EP-LOOPOPTEND-ERR: Could not parse pipeline 'bad'. I'm going to ignore it. -; RUN: opt -passes-ep-scalar-optimizer-late=bad -passes=no-op-function \ -; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=PASSES-EP-SCALAROPTLATE-ERR -; PASSES-EP-SCALAROPTLATE-ERR: Could not parse pipeline 'bad'. I'm going to ignore it. -; RUN: opt -passes-ep-cgscc-optimizer-late=bad -passes=no-op-function \ -; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=PASSES-EP-CGSCCOPTLATE-ERR -; PASSES-EP-CGSCCOPTLATE-ERR: Could not parse pipeline 'bad'. I'm going to ignore it. -; RUN: opt -passes-ep-vectorizer-start=bad -passes=no-op-function \ -; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=PASSES-EP-VECTORIZERSTART-ERR -; PASSES-EP-VECTORIZERSTART-ERR: Could not parse pipeline 'bad'. I'm going to ignore it. -; RUN: opt -passes-ep-pipeline-start=bad -passes=no-op-function \ -; RUN: /dev/null -disable-output 2>&1 | FileCheck %s -check-prefix=PASSES-EP-PIPELINESTART-ERR -; PASSES-EP-PIPELINESTART-ERR: Could not parse pipeline 'bad'. I'm going to ignore it. +; CHECK-EMPTY-PIPELINE-ON-PASS: unable to parse pass pipeline description define void @f() { entry: diff --git a/llvm/test/tools/llvm-lto2/X86/pipeline.ll b/llvm/test/tools/llvm-lto2/X86/pipeline.ll index 9ab81ac70a7..29276d8d13a 100644 --- a/llvm/test/tools/llvm-lto2/X86/pipeline.ll +++ b/llvm/test/tools/llvm-lto2/X86/pipeline.ll @@ -32,11 +32,11 @@ define void @patatino() { ; RUN: -r %t1.bc,patatino,px -opt-pipeline foogoo 2>&1 | \ ; RUN: FileCheck %s --check-prefix=ERR -; ERR: LLVM ERROR: unable to parse pass pipeline description 'foogoo': unknown pass name 'foogoo' +; ERR: LLVM ERROR: unable to parse pass pipeline description: foogoo ; RUN: not llvm-lto2 run %t1.bc -o %t.o \ ; RUN: -r %t1.bc,patatino,px -aa-pipeline patatino \ ; RUN: -opt-pipeline loweratomic 2>&1 | \ ; RUN: FileCheck %s --check-prefix=AAERR -; AAERR: LLVM ERROR: unable to parse AA pipeline description 'patatino': unknown alias analysis name 'patatino' +; AAERR: LLVM ERROR: unable to parse AA pipeline description: patatino diff --git a/llvm/test/tools/llvm-opt-fuzzer/command-line.ll b/llvm/test/tools/llvm-opt-fuzzer/command-line.ll index 8c3f6b60154..f747bba431b 100644 --- a/llvm/test/tools/llvm-opt-fuzzer/command-line.ll +++ b/llvm/test/tools/llvm-opt-fuzzer/command-line.ll @@ -13,7 +13,7 @@ ; Don't start with incorrect passes specified ; RUN: not llvm-opt-fuzzer %t -ignore_remaining_args=1 -mtriple x86_64 -passes no-pass 2>&1 | FileCheck -check-prefix=PIPELINE %s -; PIPELINE: unknown pass name 'no-pass' +; PIPELINE: can't parse pass pipeline ; Correct command line ; RUN: llvm-opt-fuzzer %t -ignore_remaining_args=1 -mtriple x86_64 -passes instcombine 2>&1 | FileCheck -check-prefix=CORRECT %s diff --git a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp index 57e75b1db9e..98d5428ddd1 100644 --- a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp +++ b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp @@ -144,10 +144,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { PB.registerLoopAnalyses(LAM); PB.crossRegisterProxies(LAM, FAM, CGAM, MAM); - auto Err = PB.parsePassPipeline(MPM, PassPipeline, false, false); - assert(!Err && "Should have been checked during fuzzer initialization"); - // Only fail with assert above, otherwise ignore the parsing error. - consumeError(std::move(Err)); + bool Ok = PB.parsePassPipeline(MPM, PassPipeline, false, false); + assert(Ok && "Should have been checked during fuzzer initialization"); + (void)Ok; // silence unused variable warning on release builds // Run passes which we need to test // @@ -236,8 +235,8 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize( PassBuilder PB(TM.get()); ModulePassManager MPM; - if (auto Err = PB.parsePassPipeline(MPM, PassPipeline, false, false)) { - errs() << *argv[0] << ": " << toString(std::move(Err)) << "\n"; + if (!PB.parsePassPipeline(MPM, PassPipeline, false, false)) { + errs() << *argv[0] << ": can't parse pass pipeline\n"; exit(1); } diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp index 11879d26a6c..e63547a79d0 100644 --- a/llvm/tools/opt/NewPMDriver.cpp +++ b/llvm/tools/opt/NewPMDriver.cpp @@ -124,12 +124,12 @@ bool tryParsePipelineText(PassBuilder &PB, StringRef PipelineText) { // Verify the pipeline is parseable: PassManagerT PM; - if (auto Err = PB.parsePassPipeline(PM, PipelineText)) { - errs() << "Could not parse pipeline '" << PipelineText - << "'. I'm going to ignore it.\n"; - return false; - } - return true; + if (PB.parsePassPipeline(PM, PipelineText)) + return true; + + errs() << "Could not parse pipeline '" << PipelineText + << "'. I'm going to igore it.\n"; + return false; } /// If one of the EPPipeline command line options was given, register callbacks @@ -137,61 +137,50 @@ bool tryParsePipelineText(PassBuilder &PB, StringRef PipelineText) { static void registerEPCallbacks(PassBuilder &PB, bool VerifyEachPass, bool DebugLogging) { if (tryParsePipelineText<FunctionPassManager>(PB, PeepholeEPPipeline)) - PB.registerPeepholeEPCallback( - [&PB, VerifyEachPass, DebugLogging]( - FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) { - ExitOnError Err("Unable to parse PeepholeEP pipeline: "); - Err(PB.parsePassPipeline(PM, PeepholeEPPipeline, VerifyEachPass, - DebugLogging)); - }); + PB.registerPeepholeEPCallback([&PB, VerifyEachPass, DebugLogging]( + FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) { + PB.parsePassPipeline(PM, PeepholeEPPipeline, VerifyEachPass, + DebugLogging); + }); if (tryParsePipelineText<LoopPassManager>(PB, LateLoopOptimizationsEPPipeline)) PB.registerLateLoopOptimizationsEPCallback( [&PB, VerifyEachPass, DebugLogging]( LoopPassManager &PM, PassBuilder::OptimizationLevel Level) { - ExitOnError Err("Unable to parse LateLoopOptimizationsEP pipeline: "); - Err(PB.parsePassPipeline(PM, LateLoopOptimizationsEPPipeline, - VerifyEachPass, DebugLogging)); + PB.parsePassPipeline(PM, LateLoopOptimizationsEPPipeline, + VerifyEachPass, DebugLogging); }); if (tryParsePipelineText<LoopPassManager>(PB, LoopOptimizerEndEPPipeline)) - PB.registerLoopOptimizerEndEPCallback( - [&PB, VerifyEachPass, DebugLogging]( - LoopPassManager &PM, PassBuilder::OptimizationLevel Level) { - ExitOnError Err("Unable to parse LoopOptimizerEndEP pipeline: "); - Err(PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline, - VerifyEachPass, DebugLogging)); - }); + PB.registerLoopOptimizerEndEPCallback([&PB, VerifyEachPass, DebugLogging]( + LoopPassManager &PM, PassBuilder::OptimizationLevel Level) { + PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline, VerifyEachPass, + DebugLogging); + }); if (tryParsePipelineText<FunctionPassManager>(PB, ScalarOptimizerLateEPPipeline)) PB.registerScalarOptimizerLateEPCallback( [&PB, VerifyEachPass, DebugLogging]( FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) { - ExitOnError Err("Unable to parse ScalarOptimizerLateEP pipeline: "); - Err(PB.parsePassPipeline(PM, ScalarOptimizerLateEPPipeline, - VerifyEachPass, DebugLogging)); + PB.parsePassPipeline(PM, ScalarOptimizerLateEPPipeline, + VerifyEachPass, DebugLogging); }); if (tryParsePipelineText<CGSCCPassManager>(PB, CGSCCOptimizerLateEPPipeline)) - PB.registerCGSCCOptimizerLateEPCallback( - [&PB, VerifyEachPass, DebugLogging]( - CGSCCPassManager &PM, PassBuilder::OptimizationLevel Level) { - ExitOnError Err("Unable to parse CGSCCOptimizerLateEP pipeline: "); - Err(PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline, - VerifyEachPass, DebugLogging)); - }); + PB.registerCGSCCOptimizerLateEPCallback([&PB, VerifyEachPass, DebugLogging]( + CGSCCPassManager &PM, PassBuilder::OptimizationLevel Level) { + PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline, VerifyEachPass, + DebugLogging); + }); if (tryParsePipelineText<FunctionPassManager>(PB, VectorizerStartEPPipeline)) - PB.registerVectorizerStartEPCallback( - [&PB, VerifyEachPass, DebugLogging]( - FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) { - ExitOnError Err("Unable to parse VectorizerStartEP pipeline: "); - Err(PB.parsePassPipeline(PM, VectorizerStartEPPipeline, - VerifyEachPass, DebugLogging)); - }); + PB.registerVectorizerStartEPCallback([&PB, VerifyEachPass, DebugLogging]( + FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) { + PB.parsePassPipeline(PM, VectorizerStartEPPipeline, VerifyEachPass, + DebugLogging); + }); if (tryParsePipelineText<ModulePassManager>(PB, PipelineStartEPPipeline)) PB.registerPipelineStartEPCallback( [&PB, VerifyEachPass, DebugLogging](ModulePassManager &PM) { - ExitOnError Err("Unable to parse PipelineStartEP pipeline: "); - Err(PB.parsePassPipeline(PM, PipelineStartEPPipeline, VerifyEachPass, - DebugLogging)); + PB.parsePassPipeline(PM, PipelineStartEPPipeline, VerifyEachPass, + DebugLogging); }); } @@ -269,8 +258,8 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM, // Specially handle the alias analysis manager so that we can register // a custom pipeline of AA passes with it. AAManager AA; - if (auto Err = PB.parseAAPipeline(AA, AAPipeline)) { - errs() << Arg0 << ": " << toString(std::move(Err)) << "\n"; + if (!PB.parseAAPipeline(AA, AAPipeline)) { + errs() << Arg0 << ": unable to parse AA pipeline description.\n"; return false; } @@ -295,9 +284,8 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM, if (EnableDebugify) MPM.addPass(NewPMDebugifyPass()); - if (auto Err = - PB.parsePassPipeline(MPM, PassPipeline, VerifyEachPass, DebugPM)) { - errs() << Arg0 << ": " << toString(std::move(Err)) << "\n"; + if (!PB.parsePassPipeline(MPM, PassPipeline, VerifyEachPass, DebugPM)) { + errs() << Arg0 << ": unable to parse pass pipeline description.\n"; return false; } diff --git a/llvm/unittests/IR/CMakeLists.txt b/llvm/unittests/IR/CMakeLists.txt index 7498983b260..211ab109131 100644 --- a/llvm/unittests/IR/CMakeLists.txt +++ b/llvm/unittests/IR/CMakeLists.txt @@ -40,5 +40,3 @@ add_llvm_unittest(IRTests VerifierTest.cpp WaymarkTest.cpp ) - -target_link_libraries(IRTests PRIVATE LLVMTestingSupport) diff --git a/llvm/unittests/IR/PassBuilderCallbacksTest.cpp b/llvm/unittests/IR/PassBuilderCallbacksTest.cpp index 20c47b045e7..97bbb81a6b0 100644 --- a/llvm/unittests/IR/PassBuilderCallbacksTest.cpp +++ b/llvm/unittests/IR/PassBuilderCallbacksTest.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Testing/Support/Error.h" #include <functional> #include <gmock/gmock.h> #include <gtest/gtest.h> @@ -461,7 +460,7 @@ TEST_F(ModuleCallbacksTest, Passes) { .WillOnce(Invoke(getAnalysisResult)); StringRef PipelineText = "test-transform"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); @@ -495,7 +494,7 @@ TEST_F(ModuleCallbacksTest, InstrumentedPasses) { .InSequence(PISequence); StringRef PipelineText = "test-transform"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); @@ -526,7 +525,7 @@ TEST_F(ModuleCallbacksTest, InstrumentedSkippedPasses) { .Times(0); StringRef PipelineText = "test-transform"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); @@ -538,7 +537,7 @@ TEST_F(FunctionCallbacksTest, Passes) { .WillOnce(Invoke(getAnalysisResult)); StringRef PipelineText = "test-transform"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); } @@ -572,7 +571,7 @@ TEST_F(FunctionCallbacksTest, InstrumentedPasses) { .InSequence(PISequence); StringRef PipelineText = "test-transform"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); } @@ -605,7 +604,7 @@ TEST_F(FunctionCallbacksTest, InstrumentedSkippedPasses) { .Times(0); StringRef PipelineText = "test-transform"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); } @@ -616,7 +615,7 @@ TEST_F(LoopCallbacksTest, Passes) { .WillOnce(WithArgs<0, 1, 2>(Invoke(getAnalysisResult))); StringRef PipelineText = "test-transform"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); } @@ -651,7 +650,7 @@ TEST_F(LoopCallbacksTest, InstrumentedPasses) { .InSequence(PISequence); StringRef PipelineText = "test-transform"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); } @@ -683,7 +682,7 @@ TEST_F(LoopCallbacksTest, InstrumentedSkippedPasses) { .Times(0); StringRef PipelineText = "test-transform"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); } @@ -694,7 +693,7 @@ TEST_F(CGSCCCallbacksTest, Passes) { .WillOnce(WithArgs<0, 1, 2>(Invoke(getAnalysisResult))); StringRef PipelineText = "test-transform"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); } @@ -728,7 +727,7 @@ TEST_F(CGSCCCallbacksTest, InstrumentedPasses) { .InSequence(PISequence); StringRef PipelineText = "test-transform"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); } @@ -760,7 +759,7 @@ TEST_F(CGSCCCallbacksTest, InstrumentedSkippedPasses) { .Times(0); StringRef PipelineText = "test-transform"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); } @@ -775,7 +774,7 @@ TEST_F(ModuleCallbacksTest, AnalysisUtilities) { EXPECT_CALL(AnalysisHandle, invalidate(HasName("<string>"), _, _)); StringRef PipelineText = "require<test-analysis>,invalidate<test-analysis>"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); } @@ -785,7 +784,7 @@ TEST_F(CGSCCCallbacksTest, PassUtilities) { EXPECT_CALL(AnalysisHandle, invalidate(HasName("(foo)"), _, _)); StringRef PipelineText = "require<test-analysis>,invalidate<test-analysis>"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); } @@ -795,7 +794,7 @@ TEST_F(FunctionCallbacksTest, AnalysisUtilities) { EXPECT_CALL(AnalysisHandle, invalidate(HasName("foo"), _, _)); StringRef PipelineText = "require<test-analysis>,invalidate<test-analysis>"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); } @@ -806,7 +805,7 @@ TEST_F(LoopCallbacksTest, PassUtilities) { StringRef PipelineText = "require<test-analysis>,invalidate<test-analysis>"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); } @@ -846,13 +845,13 @@ TEST_F(ModuleCallbacksTest, ParseTopLevelPipeline) { StringRef PipelineText = "another-pipeline(test-transform,invalidate<test-analysis>)"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded()) + ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; PM.run(*M, AM); /// Test the negative case PipelineText = "another-pipeline(instcombine)"; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Failed()) + ASSERT_FALSE(PB.parsePassPipeline(PM, PipelineText, true)) << "Pipeline was: " << PipelineText; } } // end anonymous namespace diff --git a/llvm/unittests/Passes/CMakeLists.txt b/llvm/unittests/Passes/CMakeLists.txt index 415f3a71734..d90df209d4e 100644 --- a/llvm/unittests/Passes/CMakeLists.txt +++ b/llvm/unittests/Passes/CMakeLists.txt @@ -12,7 +12,6 @@ add_llvm_unittest(PluginsTests PluginsTest.cpp ) export_executable_symbols(PluginsTests) -target_link_libraries(PluginsTests PRIVATE LLVMTestingSupport) set(LLVM_LINK_COMPONENTS) add_llvm_loadable_module(TestPlugin diff --git a/llvm/unittests/Passes/PluginsTest.cpp b/llvm/unittests/Passes/PluginsTest.cpp index abb7b57ee0c..726978714e8 100644 --- a/llvm/unittests/Passes/PluginsTest.cpp +++ b/llvm/unittests/Passes/PluginsTest.cpp @@ -15,7 +15,6 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Path.h" -#include "llvm/Testing/Support/Error.h" #include "llvm/Transforms/Scalar/LoopPassManager.h" #include "gtest/gtest.h" @@ -55,8 +54,8 @@ TEST(PluginsTests, LoadPlugin) { PassBuilder PB; ModulePassManager PM; - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, "plugin-pass"), Failed()); + ASSERT_FALSE(PB.parsePassPipeline(PM, "plugin-pass")); Plugin->registerPassBuilderCallbacks(PB); - ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, "plugin-pass"), Succeeded()); + ASSERT_TRUE(PB.parsePassPipeline(PM, "plugin-pass")); } |

