[llvm] 6dcbea8 - [NewPM] Use PassInstrumentation for -verify-each
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 7 19:24:42 PDT 2020
Author: Arthur Eubanks
Date: 2020-10-07T19:24:25-07:00
New Revision: 6dcbea877bffcd5871cf6002616a5dcdfece0b86
URL: https://github.com/llvm/llvm-project/commit/6dcbea877bffcd5871cf6002616a5dcdfece0b86
DIFF: https://github.com/llvm/llvm-project/commit/6dcbea877bffcd5871cf6002616a5dcdfece0b86.diff
LOG: [NewPM] Use PassInstrumentation for -verify-each
This removes "VerifyEachPass" parameters from a lot of functions which is nice.
Don't verify after special passes or VerifierPass.
This introduces verification on loop and cgscc passes, verifying the corresponding function/module.
Reviewed By: ychen
Differential Revision: https://reviews.llvm.org/D88764
Added:
llvm/test/Other/new-pass-manager-verify-each.ll
Modified:
llvm/include/llvm/Passes/PassBuilder.h
llvm/include/llvm/Passes/StandardInstrumentations.h
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/StandardInstrumentations.cpp
llvm/test/Other/new-pass-manager.ll
llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
llvm/tools/opt/NewPMDriver.cpp
llvm/unittests/IR/PassBuilderCallbacksTest.cpp
polly/lib/Support/RegisterPasses.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Passes/PassBuilder.h b/llvm/include/llvm/Passes/PassBuilder.h
index 73ee6092d747..aef9d9b6bb4c 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -488,7 +488,6 @@ class PassBuilder {
/// preferred when a pipeline is largely of one type, but one or just a few
/// passes are of
diff erent types(See PassBuilder.cpp for examples).
Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText,
- bool VerifyEachPass = true,
bool DebugLogging = false);
/// {{@ Parse a textual pass pipeline description into a specific PassManager
@@ -499,13 +498,10 @@ class PassBuilder {
///
/// 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);
/// @}}
@@ -682,7 +678,7 @@ class PassBuilder {
/// PassManagers and populate the passed ModulePassManager.
void registerParseTopLevelPipelineCallback(
const std::function<bool(ModulePassManager &, ArrayRef<PipelineElement>,
- bool VerifyEachPass, bool DebugLogging)> &C);
+ bool DebugLogging)> &C);
/// Add PGOInstrumenation passes for O0 only.
void addPGOInstrPassesForO0(ModulePassManager &MPM, bool DebugLogging,
@@ -706,27 +702,27 @@ class PassBuilder {
parsePipelineText(StringRef Text);
Error parseModulePass(ModulePassManager &MPM, const PipelineElement &E,
- bool VerifyEachPass, bool DebugLogging);
+ bool DebugLogging);
Error parseCGSCCPass(CGSCCPassManager &CGPM, const PipelineElement &E,
- bool VerifyEachPass, bool DebugLogging);
+ bool DebugLogging);
Error parseFunctionPass(FunctionPassManager &FPM, const PipelineElement &E,
- bool VerifyEachPass, bool DebugLogging);
+ bool DebugLogging);
Error parseLoopPass(LoopPassManager &LPM, const PipelineElement &E,
- bool VerifyEachPass, bool DebugLogging);
+ bool DebugLogging);
bool parseAAPassName(AAManager &AA, StringRef Name);
Error parseLoopPassPipeline(LoopPassManager &LPM,
ArrayRef<PipelineElement> Pipeline,
- bool VerifyEachPass, bool DebugLogging);
+ bool DebugLogging);
Error parseFunctionPassPipeline(FunctionPassManager &FPM,
ArrayRef<PipelineElement> Pipeline,
- bool VerifyEachPass, bool DebugLogging);
+ bool DebugLogging);
Error parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
ArrayRef<PipelineElement> Pipeline,
- bool VerifyEachPass, bool DebugLogging);
+ bool DebugLogging);
Error parseModulePassPipeline(ModulePassManager &MPM,
ArrayRef<PipelineElement> Pipeline,
- bool VerifyEachPass, bool DebugLogging);
+ bool DebugLogging);
void addPGOInstrPasses(ModulePassManager &MPM, bool DebugLogging,
OptimizationLevel Level, bool RunProfileGen, bool IsCS,
@@ -759,7 +755,7 @@ class PassBuilder {
2>
ModulePipelineParsingCallbacks;
SmallVector<std::function<bool(ModulePassManager &, ArrayRef<PipelineElement>,
- bool VerifyEachPass, bool DebugLogging)>,
+ bool DebugLogging)>,
2>
TopLevelPipelineParsingCallbacks;
// CGSCC callbacks
diff --git a/llvm/include/llvm/Passes/StandardInstrumentations.h b/llvm/include/llvm/Passes/StandardInstrumentations.h
index 9d03aeb6cec4..f7067c88d28e 100644
--- a/llvm/include/llvm/Passes/StandardInstrumentations.h
+++ b/llvm/include/llvm/Passes/StandardInstrumentations.h
@@ -213,6 +213,14 @@ class IRChangePrinter : public ChangePrinter<std::string> {
raw_ostream &Out;
};
+class VerifyInstrumentation {
+ bool DebugLogging;
+
+public:
+ VerifyInstrumentation(bool DebugLogging) : DebugLogging(DebugLogging) {}
+ void registerCallbacks(PassInstrumentationCallbacks &PIC);
+};
+
/// This class provides an interface to register all the standard pass
/// instrumentations and manages their state (if any).
class StandardInstrumentations {
@@ -222,9 +230,13 @@ class StandardInstrumentations {
OptNoneInstrumentation OptNone;
PreservedCFGCheckerInstrumentation PreservedCFGChecker;
IRChangePrinter PrintChangedIR;
+ VerifyInstrumentation Verify;
+
+ bool VerifyEach;
public:
- StandardInstrumentations(bool DebugLogging) : PrintPass(DebugLogging) {}
+ StandardInstrumentations(bool DebugLogging, bool VerifyEach = false)
+ : PrintPass(DebugLogging), Verify(DebugLogging), VerifyEach(VerifyEach) {}
void registerCallbacks(PassInstrumentationCallbacks &PIC);
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 92724ed22d02..b786e3dab937 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -2133,7 +2133,7 @@ PassBuilder::parsePipelineText(StringRef Text) {
Error PassBuilder::parseModulePass(ModulePassManager &MPM,
const PipelineElement &E,
- bool VerifyEachPass, bool DebugLogging) {
+ bool DebugLogging) {
auto &Name = E.Name;
auto &InnerPipeline = E.InnerPipeline;
@@ -2141,32 +2141,31 @@ Error PassBuilder::parseModulePass(ModulePassManager &MPM,
if (!InnerPipeline.empty()) {
if (Name == "module") {
ModulePassManager NestedMPM(DebugLogging);
- if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline,
- VerifyEachPass, DebugLogging))
+ if (auto Err =
+ parseModulePassPipeline(NestedMPM, InnerPipeline, DebugLogging))
return Err;
MPM.addPass(std::move(NestedMPM));
return Error::success();
}
if (Name == "cgscc") {
CGSCCPassManager CGPM(DebugLogging);
- if (auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline, VerifyEachPass,
- DebugLogging))
+ if (auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline, DebugLogging))
return Err;
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
return Error::success();
}
if (Name == "function") {
FunctionPassManager FPM(DebugLogging);
- if (auto Err = parseFunctionPassPipeline(FPM, InnerPipeline,
- VerifyEachPass, DebugLogging))
+ if (auto Err =
+ parseFunctionPassPipeline(FPM, InnerPipeline, DebugLogging))
return Err;
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
return Error::success();
}
if (auto Count = parseRepeatPassName(Name)) {
ModulePassManager NestedMPM(DebugLogging);
- if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline,
- VerifyEachPass, DebugLogging))
+ if (auto Err =
+ parseModulePassPipeline(NestedMPM, InnerPipeline, DebugLogging))
return Err;
MPM.addPass(createRepeatedPass(*Count, std::move(NestedMPM)));
return Error::success();
@@ -2315,8 +2314,7 @@ Error PassBuilder::parseModulePass(ModulePassManager &MPM,
}
Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM,
- const PipelineElement &E, bool VerifyEachPass,
- bool DebugLogging) {
+ const PipelineElement &E, bool DebugLogging) {
auto &Name = E.Name;
auto &InnerPipeline = E.InnerPipeline;
@@ -2324,8 +2322,8 @@ Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM,
if (!InnerPipeline.empty()) {
if (Name == "cgscc") {
CGSCCPassManager NestedCGPM(DebugLogging);
- if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline,
- VerifyEachPass, DebugLogging))
+ if (auto Err =
+ parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, DebugLogging))
return Err;
// Add the nested pass manager with the appropriate adaptor.
CGPM.addPass(std::move(NestedCGPM));
@@ -2333,8 +2331,8 @@ Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM,
}
if (Name == "function") {
FunctionPassManager FPM(DebugLogging);
- if (auto Err = parseFunctionPassPipeline(FPM, InnerPipeline,
- VerifyEachPass, DebugLogging))
+ if (auto Err =
+ parseFunctionPassPipeline(FPM, InnerPipeline, DebugLogging))
return Err;
// Add the nested pass manager with the appropriate adaptor.
CGPM.addPass(createCGSCCToFunctionPassAdaptor(std::move(FPM)));
@@ -2342,16 +2340,16 @@ Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM,
}
if (auto Count = parseRepeatPassName(Name)) {
CGSCCPassManager NestedCGPM(DebugLogging);
- if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline,
- VerifyEachPass, DebugLogging))
+ if (auto Err =
+ parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, DebugLogging))
return Err;
CGPM.addPass(createRepeatedPass(*Count, std::move(NestedCGPM)));
return Error::success();
}
if (auto MaxRepetitions = parseDevirtPassName(Name)) {
CGSCCPassManager NestedCGPM(DebugLogging);
- if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline,
- VerifyEachPass, DebugLogging))
+ if (auto Err =
+ parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, DebugLogging))
return Err;
CGPM.addPass(
createDevirtSCCRepeatedPass(std::move(NestedCGPM), *MaxRepetitions));
@@ -2429,7 +2427,7 @@ Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM,
Error PassBuilder::parseFunctionPass(FunctionPassManager &FPM,
const PipelineElement &E,
- bool VerifyEachPass, bool DebugLogging) {
+ bool DebugLogging) {
auto &Name = E.Name;
auto &InnerPipeline = E.InnerPipeline;
@@ -2437,8 +2435,8 @@ Error PassBuilder::parseFunctionPass(FunctionPassManager &FPM,
if (!InnerPipeline.empty()) {
if (Name == "function") {
FunctionPassManager NestedFPM(DebugLogging);
- if (auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline,
- VerifyEachPass, DebugLogging))
+ if (auto Err =
+ parseFunctionPassPipeline(NestedFPM, InnerPipeline, DebugLogging))
return Err;
// Add the nested pass manager with the appropriate adaptor.
FPM.addPass(std::move(NestedFPM));
@@ -2446,8 +2444,7 @@ Error PassBuilder::parseFunctionPass(FunctionPassManager &FPM,
}
if (Name == "loop" || Name == "loop-mssa") {
LoopPassManager LPM(DebugLogging);
- if (auto Err = parseLoopPassPipeline(LPM, InnerPipeline, VerifyEachPass,
- DebugLogging))
+ if (auto Err = parseLoopPassPipeline(LPM, InnerPipeline, DebugLogging))
return Err;
// Add the nested pass manager with the appropriate adaptor.
bool UseMemorySSA = (Name == "loop-mssa");
@@ -2460,8 +2457,8 @@ Error PassBuilder::parseFunctionPass(FunctionPassManager &FPM,
}
if (auto Count = parseRepeatPassName(Name)) {
FunctionPassManager NestedFPM(DebugLogging);
- if (auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline,
- VerifyEachPass, DebugLogging))
+ if (auto Err =
+ parseFunctionPassPipeline(NestedFPM, InnerPipeline, DebugLogging))
return Err;
FPM.addPass(createRepeatedPass(*Count, std::move(NestedFPM)));
return Error::success();
@@ -2533,7 +2530,7 @@ Error PassBuilder::parseFunctionPass(FunctionPassManager &FPM,
}
Error PassBuilder::parseLoopPass(LoopPassManager &LPM, const PipelineElement &E,
- bool VerifyEachPass, bool DebugLogging) {
+ bool DebugLogging) {
StringRef Name = E.Name;
auto &InnerPipeline = E.InnerPipeline;
@@ -2541,8 +2538,8 @@ 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))
+ if (auto Err =
+ parseLoopPassPipeline(NestedLPM, InnerPipeline, DebugLogging))
return Err;
// Add the nested pass manager with the appropriate adaptor.
LPM.addPass(std::move(NestedLPM));
@@ -2550,8 +2547,8 @@ Error PassBuilder::parseLoopPass(LoopPassManager &LPM, const PipelineElement &E,
}
if (auto Count = parseRepeatPassName(Name)) {
LoopPassManager NestedLPM(DebugLogging);
- if (auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline,
- VerifyEachPass, DebugLogging))
+ if (auto Err =
+ parseLoopPassPipeline(NestedLPM, InnerPipeline, DebugLogging))
return Err;
LPM.addPass(createRepeatedPass(*Count, std::move(NestedLPM)));
return Error::success();
@@ -2626,38 +2623,30 @@ bool PassBuilder::parseAAPassName(AAManager &AA, StringRef Name) {
Error PassBuilder::parseLoopPassPipeline(LoopPassManager &LPM,
ArrayRef<PipelineElement> Pipeline,
- bool VerifyEachPass,
bool DebugLogging) {
for (const auto &Element : Pipeline) {
- if (auto Err = parseLoopPass(LPM, Element, VerifyEachPass, DebugLogging))
+ if (auto Err = parseLoopPass(LPM, Element, DebugLogging))
return Err;
- // FIXME: No verifier support for Loop passes!
}
return Error::success();
}
Error PassBuilder::parseFunctionPassPipeline(FunctionPassManager &FPM,
ArrayRef<PipelineElement> Pipeline,
- bool VerifyEachPass,
bool DebugLogging) {
for (const auto &Element : Pipeline) {
- if (auto Err =
- parseFunctionPass(FPM, Element, VerifyEachPass, DebugLogging))
+ if (auto Err = parseFunctionPass(FPM, Element, DebugLogging))
return Err;
- if (VerifyEachPass)
- FPM.addPass(VerifierPass());
}
return Error::success();
}
Error PassBuilder::parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
ArrayRef<PipelineElement> Pipeline,
- bool VerifyEachPass,
bool DebugLogging) {
for (const auto &Element : Pipeline) {
- if (auto Err = parseCGSCCPass(CGPM, Element, VerifyEachPass, DebugLogging))
+ if (auto Err = parseCGSCCPass(CGPM, Element, DebugLogging))
return Err;
- // FIXME: No verifier support for CGSCC passes!
}
return Error::success();
}
@@ -2677,13 +2666,10 @@ void PassBuilder::crossRegisterProxies(LoopAnalysisManager &LAM,
Error PassBuilder::parseModulePassPipeline(ModulePassManager &MPM,
ArrayRef<PipelineElement> Pipeline,
- bool VerifyEachPass,
bool DebugLogging) {
for (const auto &Element : Pipeline) {
- if (auto Err = parseModulePass(MPM, Element, VerifyEachPass, DebugLogging))
+ if (auto Err = parseModulePass(MPM, Element, DebugLogging))
return Err;
- if (VerifyEachPass)
- MPM.addPass(VerifierPass());
}
return Error::success();
}
@@ -2693,7 +2679,7 @@ Error PassBuilder::parseModulePassPipeline(ModulePassManager &MPM,
// pre-populate the analysis managers with target-specific stuff?
Error PassBuilder::parsePassPipeline(ModulePassManager &MPM,
StringRef PipelineText,
- bool VerifyEachPass, bool DebugLogging) {
+ bool DebugLogging) {
auto Pipeline = parsePipelineText(PipelineText);
if (!Pipeline || Pipeline->empty())
return make_error<StringError>(
@@ -2714,7 +2700,7 @@ Error PassBuilder::parsePassPipeline(ModulePassManager &MPM,
Pipeline = {{"function", {{"loop", std::move(*Pipeline)}}}};
} else {
for (auto &C : TopLevelPipelineParsingCallbacks)
- if (C(MPM, *Pipeline, VerifyEachPass, DebugLogging))
+ if (C(MPM, *Pipeline, DebugLogging))
return Error::success();
// Unknown pass or pipeline name!
@@ -2727,8 +2713,7 @@ Error PassBuilder::parsePassPipeline(ModulePassManager &MPM,
}
}
- if (auto Err =
- parseModulePassPipeline(MPM, *Pipeline, VerifyEachPass, DebugLogging))
+ if (auto Err = parseModulePassPipeline(MPM, *Pipeline, DebugLogging))
return Err;
return Error::success();
}
@@ -2736,7 +2721,7 @@ Error PassBuilder::parsePassPipeline(ModulePassManager &MPM,
// Primary pass pipeline description parsing routine for a \c CGSCCPassManager
Error PassBuilder::parsePassPipeline(CGSCCPassManager &CGPM,
StringRef PipelineText,
- bool VerifyEachPass, bool DebugLogging) {
+ bool DebugLogging) {
auto Pipeline = parsePipelineText(PipelineText);
if (!Pipeline || Pipeline->empty())
return make_error<StringError>(
@@ -2751,8 +2736,7 @@ Error PassBuilder::parsePassPipeline(CGSCCPassManager &CGPM,
.str(),
inconvertibleErrorCode());
- if (auto Err =
- parseCGSCCPassPipeline(CGPM, *Pipeline, VerifyEachPass, DebugLogging))
+ if (auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline, DebugLogging))
return Err;
return Error::success();
}
@@ -2761,7 +2745,7 @@ Error PassBuilder::parsePassPipeline(CGSCCPassManager &CGPM,
// FunctionPassManager
Error PassBuilder::parsePassPipeline(FunctionPassManager &FPM,
StringRef PipelineText,
- bool VerifyEachPass, bool DebugLogging) {
+ bool DebugLogging) {
auto Pipeline = parsePipelineText(PipelineText);
if (!Pipeline || Pipeline->empty())
return make_error<StringError>(
@@ -2776,8 +2760,7 @@ Error PassBuilder::parsePassPipeline(FunctionPassManager &FPM,
.str(),
inconvertibleErrorCode());
- if (auto Err = parseFunctionPassPipeline(FPM, *Pipeline, VerifyEachPass,
- DebugLogging))
+ if (auto Err = parseFunctionPassPipeline(FPM, *Pipeline, DebugLogging))
return Err;
return Error::success();
}
@@ -2785,15 +2768,14 @@ Error PassBuilder::parsePassPipeline(FunctionPassManager &FPM,
// Primary pass pipeline description parsing routine for a \c LoopPassManager
Error PassBuilder::parsePassPipeline(LoopPassManager &CGPM,
StringRef PipelineText,
- bool VerifyEachPass, bool DebugLogging) {
+ 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))
+ if (auto Err = parseLoopPassPipeline(CGPM, *Pipeline, DebugLogging))
return Err;
return Error::success();
@@ -2855,6 +2837,6 @@ bool PassBuilder::isAnalysisPassName(StringRef PassName) {
void PassBuilder::registerParseTopLevelPipelineCallback(
const std::function<bool(ModulePassManager &, ArrayRef<PipelineElement>,
- bool VerifyEachPass, bool DebugLogging)> &C) {
+ bool DebugLogging)> &C) {
TopLevelPipelineParsingCallbacks.push_back(C);
}
diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index 06aa3868fd6d..3b591c021a7c 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -22,6 +22,7 @@
#include "llvm/IR/IRPrintingPasses.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassInstrumentation.h"
+#include "llvm/IR/Verifier.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FormatVariadic.h"
@@ -233,19 +234,19 @@ void unwrapAndPrint(raw_ostream &OS, Any IR, StringRef Banner,
}
// Return true when this is a pass for which changes should be ignored
-inline bool isIgnored(StringRef PassID) {
+bool isIgnored(StringRef PassID) {
return isSpecialPass(PassID,
{"PassManager", "PassAdaptor", "AnalysisManagerProxy"});
}
// Return true when this is a defined function for which printing
// of changes is desired.
-inline bool isInterestingFunction(const Function &F) {
+bool isInterestingFunction(const Function &F) {
return llvm::isFunctionInPrintList(F.getName());
}
// Return true when this is a pass for which printing of changes is desired.
-inline bool isInterestingPass(StringRef PassID) {
+bool isInterestingPass(StringRef PassID) {
if (isIgnored(PassID))
return false;
@@ -724,6 +725,42 @@ void PreservedCFGCheckerInstrumentation::registerCallbacks(
});
}
+void VerifyInstrumentation::registerCallbacks(
+ PassInstrumentationCallbacks &PIC) {
+ PIC.registerAfterPassCallback(
+ [this](StringRef P, Any IR, const PreservedAnalyses &PassPA) {
+ if (isIgnored(P) || P == "VerifierPass")
+ return;
+ if (any_isa<const Function *>(IR) || any_isa<const Loop *>(IR)) {
+ const Function *F;
+ if (any_isa<const Loop *>(IR))
+ F = any_cast<const Loop *>(IR)->getHeader()->getParent();
+ else
+ F = any_cast<const Function *>(IR);
+ if (DebugLogging)
+ dbgs() << "Verifying function " << F->getName() << "\n";
+
+ if (verifyFunction(*F))
+ report_fatal_error("Broken function found, compilation aborted!");
+ } else if (any_isa<const Module *>(IR) ||
+ any_isa<const LazyCallGraph::SCC *>(IR)) {
+ const Module *M;
+ if (any_isa<const LazyCallGraph::SCC *>(IR))
+ M = any_cast<const LazyCallGraph::SCC *>(IR)
+ ->begin()
+ ->getFunction()
+ .getParent();
+ else
+ M = any_cast<const Module *>(IR);
+ if (DebugLogging)
+ dbgs() << "Verifying module " << M->getName() << "\n";
+
+ if (verifyModule(*M))
+ report_fatal_error("Broken module found, compilation aborted!");
+ }
+ });
+}
+
void StandardInstrumentations::registerCallbacks(
PassInstrumentationCallbacks &PIC) {
PrintIR.registerCallbacks(PIC);
@@ -732,4 +769,6 @@ void StandardInstrumentations::registerCallbacks(
OptNone.registerCallbacks(PIC);
PreservedCFGChecker.registerCallbacks(PIC);
PrintChangedIR.registerCallbacks(PIC);
+ if (VerifyEach)
+ Verify.registerCallbacks(PIC);
}
diff --git a/llvm/test/Other/new-pass-manager-verify-each.ll b/llvm/test/Other/new-pass-manager-verify-each.ll
new file mode 100644
index 000000000000..1af48be8d120
--- /dev/null
+++ b/llvm/test/Other/new-pass-manager-verify-each.ll
@@ -0,0 +1,39 @@
+; RUN: opt -disable-output -debug-pass-manager -verify-each -passes='no-op-module,verify,cgscc(no-op-cgscc,function(no-op-function,loop(no-op-loop)))' %s 2>&1 | FileCheck %s
+
+; Added manually by opt at beginning
+; CHECK: Running pass: VerifierPass
+
+; CHECK: Running pass: NoOpModulePass
+; CHECK: Verifying module
+; CHECK-NOT: Verifying module
+; CHECK: Running pass: NoOpCGSCCPass
+; CHECK: Verifying module
+; CHECK-NOT: Verifying module
+; CHECK: Running pass: NoOpFunctionPass
+; CHECK: Verifying function foo
+; CHECK: Running pass: LoopSimplifyPass
+; CHECK: Verifying function foo
+; CHECK: Running pass: LCSSAPass
+; CHECK: Verifying function foo
+; CHECK: Running pass: NoOpLoopPass
+; CHECK: Verifying function foo
+; CHECK-NOT: Verifying function
+; CHECK-NOT: Verifying module
+
+; Added manually by opt at end
+; CHECK: Running pass: VerifierPass
+
+define void @foo(i1 %x, i8* %p1, i8* %p2) {
+entry:
+ store i8 42, i8* %p1
+ br i1 %x, label %loop, label %exit
+
+loop:
+ %tmp1 = load i8, i8* %p2
+ br label %loop
+
+exit:
+ ret void
+}
+
+declare void @bar()
diff --git a/llvm/test/Other/new-pass-manager.ll b/llvm/test/Other/new-pass-manager.ll
index 70d1f7152120..66cf4fb111e9 100644
--- a/llvm/test/Other/new-pass-manager.ll
+++ b/llvm/test/Other/new-pass-manager.ll
@@ -104,19 +104,6 @@
; RUN: | llvm-dis \
; RUN: | FileCheck %s --check-prefix=CHECK-NOOP
-; RUN: opt -disable-output -debug-pass-manager -verify-each -passes='no-op-module,function(no-op-function)' %s 2>&1 \
-; RUN: | FileCheck %s --check-prefix=CHECK-VERIFY-EACH
-; CHECK-VERIFY-EACH: Starting llvm::Module pass manager run
-; CHECK-VERIFY-EACH: Running pass: VerifierPass
-; CHECK-VERIFY-EACH: Running pass: NoOpModulePass
-; CHECK-VERIFY-EACH: Running pass: VerifierPass
-; CHECK-VERIFY-EACH: Starting llvm::Function pass manager run
-; CHECK-VERIFY-EACH: Running pass: NoOpFunctionPass
-; CHECK-VERIFY-EACH: Running pass: VerifierPass
-; CHECK-VERIFY-EACH: Finished llvm::Function pass manager run
-; CHECK-VERIFY-EACH: Running pass: VerifierPass
-; CHECK-VERIFY-EACH: Finished llvm::Module pass manager run
-
; RUN: opt -disable-output -debug-pass-manager -disable-verify -passes='no-op-module,function(no-op-function)' %s 2>&1 \
; RUN: | FileCheck %s --check-prefix=CHECK-NO-VERIFY
; CHECK-NO-VERIFY: Starting llvm::Module pass manager run
diff --git a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
index 4c672bc2a3bd..40aac7c3a281 100644
--- a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
+++ b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
@@ -148,7 +148,7 @@ 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);
+ auto Err = PB.parsePassPipeline(MPM, PassPipeline, false);
assert(!Err && "Should have been checked during fuzzer initialization");
// Only fail with assert above, otherwise ignore the parsing error.
consumeError(std::move(Err));
@@ -241,7 +241,7 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize(
PassBuilder PB(TM.get());
ModulePassManager MPM;
- if (auto Err = PB.parsePassPipeline(MPM, PassPipeline, false, false)) {
+ if (auto Err = PB.parsePassPipeline(MPM, PassPipeline, false)) {
errs() << *argv[0] << ": " << toString(std::move(Err)) << "\n";
exit(1);
}
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index f01d33efe45a..98a8454f9528 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -140,72 +140,68 @@ bool tryParsePipelineText(PassBuilder &PB,
/// If one of the EPPipeline command line options was given, register callbacks
/// for parsing and inserting the given pipeline
-static void registerEPCallbacks(PassBuilder &PB, bool VerifyEachPass,
- bool DebugLogging) {
+static void registerEPCallbacks(PassBuilder &PB, bool DebugLogging) {
if (tryParsePipelineText<FunctionPassManager>(PB, PeepholeEPPipeline))
PB.registerPeepholeEPCallback(
- [&PB, VerifyEachPass, DebugLogging](
- FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
+ [&PB, DebugLogging](FunctionPassManager &PM,
+ PassBuilder::OptimizationLevel Level) {
ExitOnError Err("Unable to parse PeepholeEP pipeline: ");
- Err(PB.parsePassPipeline(PM, PeepholeEPPipeline, VerifyEachPass,
- DebugLogging));
+ Err(PB.parsePassPipeline(PM, PeepholeEPPipeline, DebugLogging));
});
if (tryParsePipelineText<LoopPassManager>(PB,
LateLoopOptimizationsEPPipeline))
PB.registerLateLoopOptimizationsEPCallback(
- [&PB, VerifyEachPass, DebugLogging](
- LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
+ [&PB, DebugLogging](LoopPassManager &PM,
+ PassBuilder::OptimizationLevel Level) {
ExitOnError Err("Unable to parse LateLoopOptimizationsEP pipeline: ");
Err(PB.parsePassPipeline(PM, LateLoopOptimizationsEPPipeline,
- VerifyEachPass, DebugLogging));
+ DebugLogging));
});
if (tryParsePipelineText<LoopPassManager>(PB, LoopOptimizerEndEPPipeline))
PB.registerLoopOptimizerEndEPCallback(
- [&PB, VerifyEachPass, DebugLogging](
- LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
+ [&PB, DebugLogging](LoopPassManager &PM,
+ PassBuilder::OptimizationLevel Level) {
ExitOnError Err("Unable to parse LoopOptimizerEndEP pipeline: ");
Err(PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline,
- VerifyEachPass, DebugLogging));
+ DebugLogging));
});
if (tryParsePipelineText<FunctionPassManager>(PB,
ScalarOptimizerLateEPPipeline))
PB.registerScalarOptimizerLateEPCallback(
- [&PB, VerifyEachPass, DebugLogging](
- FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
+ [&PB, DebugLogging](FunctionPassManager &PM,
+ PassBuilder::OptimizationLevel Level) {
ExitOnError Err("Unable to parse ScalarOptimizerLateEP pipeline: ");
Err(PB.parsePassPipeline(PM, ScalarOptimizerLateEPPipeline,
- VerifyEachPass, DebugLogging));
+ DebugLogging));
});
if (tryParsePipelineText<CGSCCPassManager>(PB, CGSCCOptimizerLateEPPipeline))
PB.registerCGSCCOptimizerLateEPCallback(
- [&PB, VerifyEachPass, DebugLogging](
- CGSCCPassManager &PM, PassBuilder::OptimizationLevel Level) {
+ [&PB, DebugLogging](CGSCCPassManager &PM,
+ PassBuilder::OptimizationLevel Level) {
ExitOnError Err("Unable to parse CGSCCOptimizerLateEP pipeline: ");
Err(PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline,
- VerifyEachPass, DebugLogging));
+ DebugLogging));
});
if (tryParsePipelineText<FunctionPassManager>(PB, VectorizerStartEPPipeline))
PB.registerVectorizerStartEPCallback(
- [&PB, VerifyEachPass, DebugLogging](
- FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
+ [&PB, DebugLogging](FunctionPassManager &PM,
+ PassBuilder::OptimizationLevel Level) {
ExitOnError Err("Unable to parse VectorizerStartEP pipeline: ");
Err(PB.parsePassPipeline(PM, VectorizerStartEPPipeline,
- VerifyEachPass, DebugLogging));
+ DebugLogging));
});
if (tryParsePipelineText<ModulePassManager>(PB, PipelineStartEPPipeline))
PB.registerPipelineStartEPCallback(
- [&PB, VerifyEachPass, DebugLogging](ModulePassManager &PM) {
+ [&PB, DebugLogging](ModulePassManager &PM) {
ExitOnError Err("Unable to parse PipelineStartEP pipeline: ");
- Err(PB.parsePassPipeline(PM, PipelineStartEPPipeline, VerifyEachPass,
- DebugLogging));
+ Err(PB.parsePassPipeline(PM, PipelineStartEPPipeline, DebugLogging));
});
if (tryParsePipelineText<FunctionPassManager>(PB, OptimizerLastEPPipeline))
PB.registerOptimizerLastEPCallback(
- [&PB, VerifyEachPass, DebugLogging](ModulePassManager &PM,
- PassBuilder::OptimizationLevel) {
+ [&PB, DebugLogging](ModulePassManager &PM,
+ PassBuilder::OptimizationLevel) {
ExitOnError Err("Unable to parse OptimizerLastEP pipeline: ");
- Err(PB.parsePassPipeline(PM, OptimizerLastEPPipeline, VerifyEachPass,
- DebugLogging));
+ Err(PB.parsePassPipeline(PM, OptimizerLastEPPipeline, DebugLogging));
});
}
@@ -264,7 +260,7 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
}
}
PassInstrumentationCallbacks PIC;
- StandardInstrumentations SI(DebugPM);
+ StandardInstrumentations SI(DebugPM, VerifyEachPass);
SI.registerCallbacks(PIC);
PipelineTuningOptions PTO;
@@ -274,7 +270,7 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
PTO.LoopUnrolling = !DisableLoopUnrolling;
PTO.Coroutines = Coroutines;
PassBuilder PB(TM, PTO, P, &PIC);
- registerEPCallbacks(PB, VerifyEachPass, DebugPM);
+ registerEPCallbacks(PB, DebugPM);
// Load requested pass plugins and let them register pass builder callbacks
for (auto &PluginFN : PassPlugins) {
@@ -387,8 +383,7 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
if (!PassPipeline.empty()) {
assert(Passes.empty() &&
"PassPipeline and Passes should not both contain passes");
- if (auto Err =
- PB.parsePassPipeline(MPM, PassPipeline, VerifyEachPass, DebugPM)) {
+ if (auto Err = PB.parsePassPipeline(MPM, PassPipeline, DebugPM)) {
errs() << Arg0 << ": " << toString(std::move(Err)) << "\n";
return false;
}
@@ -397,8 +392,7 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
std::string ModifiedPassName(PassName.begin(), PassName.end());
if (PB.isAnalysisPassName(PassName))
ModifiedPassName = "require<" + ModifiedPassName + ">";
- if (auto Err = PB.parsePassPipeline(MPM, ModifiedPassName, VerifyEachPass,
- DebugPM)) {
+ if (auto Err = PB.parsePassPipeline(MPM, ModifiedPassName, DebugPM)) {
errs() << Arg0 << ": " << toString(std::move(Err)) << "\n";
return false;
}
diff --git a/llvm/unittests/IR/PassBuilderCallbacksTest.cpp b/llvm/unittests/IR/PassBuilderCallbacksTest.cpp
index 44c0fe9ffd16..83b9ae623932 100644
--- a/llvm/unittests/IR/PassBuilderCallbacksTest.cpp
+++ b/llvm/unittests/IR/PassBuilderCallbacksTest.cpp
@@ -502,7 +502,7 @@ TEST_F(ModuleCallbacksTest, Passes) {
.WillOnce(Invoke(getAnalysisResult));
StringRef PipelineText = "test-transform";
- ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
+ ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
@@ -547,7 +547,7 @@ TEST_F(ModuleCallbacksTest, InstrumentedPasses) {
.Times(0);
StringRef PipelineText = "test-transform";
- ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
+ ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
@@ -663,7 +663,7 @@ TEST_F(ModuleCallbacksTest, InstrumentedSkippedPasses) {
StringRef PipelineText = "test-transform,function(test-transform),cgscc("
"function(loop(test-transform)))";
- ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
+ ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
@@ -675,7 +675,7 @@ TEST_F(FunctionCallbacksTest, Passes) {
.WillOnce(Invoke(getAnalysisResult));
StringRef PipelineText = "test-transform";
- ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
+ ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
}
@@ -725,7 +725,7 @@ TEST_F(FunctionCallbacksTest, InstrumentedPasses) {
.Times(0);
StringRef PipelineText = "test-transform";
- ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
+ ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
}
@@ -771,7 +771,7 @@ TEST_F(FunctionCallbacksTest, InstrumentedSkippedPasses) {
.Times(0);
StringRef PipelineText = "test-transform";
- ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
+ ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
}
@@ -782,7 +782,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_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
}
@@ -833,7 +833,7 @@ TEST_F(LoopCallbacksTest, InstrumentedPasses) {
.Times(0);
StringRef PipelineText = "test-transform";
- ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
+ ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
}
@@ -881,7 +881,7 @@ TEST_F(LoopCallbacksTest, InstrumentedInvalidatingPasses) {
.Times(0);
StringRef PipelineText = "test-transform";
- ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
+ ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
}
@@ -925,7 +925,7 @@ TEST_F(LoopCallbacksTest, InstrumentedSkippedPasses) {
.Times(0);
StringRef PipelineText = "test-transform";
- ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
+ ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
}
@@ -936,7 +936,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_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
}
@@ -987,7 +987,7 @@ TEST_F(CGSCCCallbacksTest, InstrumentedPasses) {
.Times(0);
StringRef PipelineText = "test-transform";
- ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
+ ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
}
@@ -1035,7 +1035,7 @@ TEST_F(CGSCCCallbacksTest, InstrumentedInvalidatingPasses) {
.Times(0);
StringRef PipelineText = "test-transform";
- ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
+ ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
}
@@ -1080,7 +1080,7 @@ TEST_F(CGSCCCallbacksTest, InstrumentedSkippedPasses) {
.Times(0);
StringRef PipelineText = "test-transform";
- ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
+ ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
}
@@ -1095,7 +1095,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_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
}
@@ -1105,7 +1105,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_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
}
@@ -1115,7 +1115,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_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
}
@@ -1126,7 +1126,7 @@ TEST_F(LoopCallbacksTest, PassUtilities) {
StringRef PipelineText = "require<test-analysis>,invalidate<test-analysis>";
- ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
+ ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "Pipeline was: " << PipelineText;
PM.run(*M, AM);
}
@@ -1139,25 +1139,27 @@ TEST_F(LoopCallbacksTest, PassUtilities) {
/// This test parses a pipeline named 'another-pipeline', whose only elements
/// may be the test-transform pass or the analysis utilities
TEST_F(ModuleCallbacksTest, ParseTopLevelPipeline) {
- PB.registerParseTopLevelPipelineCallback([this](
- ModulePassManager &MPM, ArrayRef<PassBuilder::PipelineElement> Pipeline,
- bool VerifyEachPass, bool DebugLogging) {
- auto &FirstName = Pipeline.front().Name;
- auto &InnerPipeline = Pipeline.front().InnerPipeline;
- if (FirstName == "another-pipeline") {
- for (auto &E : InnerPipeline) {
- if (parseAnalysisUtilityPasses<AnalysisT>("test-analysis", E.Name, PM))
- continue;
-
- if (E.Name == "test-transform") {
- PM.addPass(PassHandle.getPass());
- continue;
+ PB.registerParseTopLevelPipelineCallback(
+ [this](ModulePassManager &MPM,
+ ArrayRef<PassBuilder::PipelineElement> Pipeline,
+ bool DebugLogging) {
+ auto &FirstName = Pipeline.front().Name;
+ auto &InnerPipeline = Pipeline.front().InnerPipeline;
+ if (FirstName == "another-pipeline") {
+ for (auto &E : InnerPipeline) {
+ if (parseAnalysisUtilityPasses<AnalysisT>("test-analysis", E.Name,
+ PM))
+ continue;
+
+ if (E.Name == "test-transform") {
+ PM.addPass(PassHandle.getPass());
+ continue;
+ }
+ return false;
+ }
}
- return false;
- }
- }
- return true;
- });
+ return true;
+ });
EXPECT_CALL(AnalysisHandle, run(HasName("<string>"), _));
EXPECT_CALL(PassHandle, run(HasName("<string>"), _))
@@ -1166,13 +1168,13 @@ TEST_F(ModuleCallbacksTest, ParseTopLevelPipeline) {
StringRef PipelineText =
"another-pipeline(test-transform,invalidate<test-analysis>)";
- ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText, true), Succeeded())
+ ASSERT_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Succeeded())
<< "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_THAT_ERROR(PB.parsePassPipeline(PM, PipelineText), Failed())
<< "Pipeline was: " << PipelineText;
}
} // end anonymous namespace
diff --git a/polly/lib/Support/RegisterPasses.cpp b/polly/lib/Support/RegisterPasses.cpp
index ad6edb5807cc..e9687df6e964 100644
--- a/polly/lib/Support/RegisterPasses.cpp
+++ b/polly/lib/Support/RegisterPasses.cpp
@@ -678,7 +678,7 @@ static bool isScopPassName(StringRef Name) {
static bool
parseTopLevelPipeline(ModulePassManager &MPM,
ArrayRef<PassBuilder::PipelineElement> Pipeline,
- bool VerifyEachPass, bool DebugLogging) {
+ bool DebugLogging) {
std::vector<PassBuilder::PipelineElement> FullPipeline;
StringRef FirstName = Pipeline.front().Name;
@@ -698,11 +698,7 @@ parseTopLevelPipeline(ModulePassManager &MPM,
}
FPM.addPass(createFunctionToScopPassAdaptor(std::move(SPM)));
- if (VerifyEachPass)
- FPM.addPass(VerifierPass());
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
- if (VerifyEachPass)
- MPM.addPass(VerifierPass());
return true;
}
More information about the llvm-commits
mailing list