/// of the built-in passes, and those may reference these members during
/// construction.
class PassBuilder {
+ bool DebugLogging;
TargetMachine *TM;
PipelineTuningOptions PTO;
Optional<PGOOptions> PGOOpt;
unsigned getSizeLevel() const { return SizeLevel; }
};
- explicit PassBuilder(TargetMachine *TM = nullptr,
+ explicit PassBuilder(bool DebugLogging = false, TargetMachine *TM = nullptr,
PipelineTuningOptions PTO = PipelineTuningOptions(),
Optional<PGOOptions> PGOOpt = None,
- PassInstrumentationCallbacks *PIC = nullptr)
- : TM(TM), PTO(PTO), PGOOpt(PGOOpt), PIC(PIC) {}
+ PassInstrumentationCallbacks *PIC = nullptr);
/// Cross register the analysis managers through their proxies.
///
/// \p Phase indicates the current ThinLTO phase.
FunctionPassManager
buildFunctionSimplificationPipeline(OptimizationLevel Level,
- ThinLTOPhase Phase,
- bool DebugLogging = false);
+ ThinLTOPhase Phase);
/// Construct the core LLVM module canonicalization and simplification
/// pipeline.
/// build them.
///
/// \p Phase indicates the current ThinLTO phase.
- ModulePassManager
- buildModuleSimplificationPipeline(OptimizationLevel Level,
- ThinLTOPhase Phase,
- bool DebugLogging = false);
+ ModulePassManager buildModuleSimplificationPipeline(OptimizationLevel Level,
+ ThinLTOPhase Phase);
/// Construct the module pipeline that performs inlining as well as
/// the inlining-driven cleanups.
ModuleInlinerWrapperPass buildInlinerPipeline(OptimizationLevel Level,
- ThinLTOPhase Phase,
- bool DebugLogging = false);
+ ThinLTOPhase Phase);
/// Construct the core LLVM module optimization pipeline.
///
/// require some transformations for semantic reasons, they should explicitly
/// build them.
ModulePassManager buildModuleOptimizationPipeline(OptimizationLevel Level,
- bool DebugLogging = false,
bool LTOPreLink = false);
/// Build a per-module default optimization pipeline.
/// require some transformations for semantic reasons, they should explicitly
/// build them.
ModulePassManager buildPerModuleDefaultPipeline(OptimizationLevel Level,
- bool DebugLogging = false,
bool LTOPreLink = false);
/// Build a pre-link, ThinLTO-targeting default optimization pipeline to
/// only intended for use when attempting to optimize code. If frontends
/// require some transformations for semantic reasons, they should explicitly
/// build them.
- ModulePassManager
- buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level,
- bool DebugLogging = false);
+ ModulePassManager buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level);
/// Build an ThinLTO default optimization pipeline to a pass manager.
///
/// require some transformations for semantic reasons, they should explicitly
/// build them.
ModulePassManager
- buildThinLTODefaultPipeline(OptimizationLevel Level, bool DebugLogging,
+ buildThinLTODefaultPipeline(OptimizationLevel Level,
const ModuleSummaryIndex *ImportSummary);
/// Build a pre-link, LTO-targeting default optimization pipeline to a pass
/// only intended for use when attempting to optimize code. If frontends
/// require some transformations for semantic reasons, they should explicitly
/// build them.
- ModulePassManager buildLTOPreLinkDefaultPipeline(OptimizationLevel Level,
- bool DebugLogging = false);
+ ModulePassManager buildLTOPreLinkDefaultPipeline(OptimizationLevel Level);
/// Build an LTO default optimization pipeline to a pass manager.
///
/// require some transformations for semantic reasons, they should explicitly
/// build them.
ModulePassManager buildLTODefaultPipeline(OptimizationLevel Level,
- bool DebugLogging,
ModuleSummaryIndex *ExportSummary);
/// Build the default `AAManager` with the default alias analysis pipeline
/// specifically want the pass to run under a adaptor directly. This is
/// preferred when a pipeline is largely of one type, but one or just a few
/// passes are of different types(See PassBuilder.cpp for examples).
- Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText,
- bool DebugLogging = false);
+ Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText);
/// {{@ Parse a textual pass pipeline description into a specific PassManager
///
/// this is the valid pipeline text:
///
/// function(lpass)
- Error parsePassPipeline(CGSCCPassManager &CGPM, StringRef PipelineText,
- bool DebugLogging = false);
- Error parsePassPipeline(FunctionPassManager &FPM, StringRef PipelineText,
- bool DebugLogging = false);
- Error parsePassPipeline(LoopPassManager &LPM, StringRef PipelineText,
- bool DebugLogging = false);
+ Error parsePassPipeline(CGSCCPassManager &CGPM, StringRef PipelineText);
+ Error parsePassPipeline(FunctionPassManager &FPM, StringRef PipelineText);
+ Error parsePassPipeline(LoopPassManager &LPM, StringRef PipelineText);
/// @}}
/// Parse a textual alias analysis pipeline into the provided AA manager.
bool DebugLogging)> &C);
/// Add PGOInstrumenation passes for O0 only.
- void addPGOInstrPassesForO0(ModulePassManager &MPM, bool DebugLogging,
- bool RunProfileGen, bool IsCS,
- std::string ProfileFile,
+ void addPGOInstrPassesForO0(ModulePassManager &MPM, bool RunProfileGen,
+ bool IsCS, std::string ProfileFile,
std::string ProfileRemappingFile);
-
/// Returns PIC. External libraries can use this to register pass
/// instrumentation callbacks.
PassInstrumentationCallbacks *getPassInstrumentationCallbacks() const {
private:
// O1 pass pipeline
- FunctionPassManager buildO1FunctionSimplificationPipeline(
- OptimizationLevel Level, ThinLTOPhase Phase, bool DebugLogging = false);
+ FunctionPassManager
+ buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
+ ThinLTOPhase Phase);
static Optional<std::vector<PipelineElement>>
parsePipelineText(StringRef Text);
- Error parseModulePass(ModulePassManager &MPM, const PipelineElement &E,
- bool DebugLogging);
- Error parseCGSCCPass(CGSCCPassManager &CGPM, const PipelineElement &E,
- bool DebugLogging);
- Error parseFunctionPass(FunctionPassManager &FPM, const PipelineElement &E,
- bool DebugLogging);
- Error parseLoopPass(LoopPassManager &LPM, const PipelineElement &E,
- bool DebugLogging);
+ Error parseModulePass(ModulePassManager &MPM, const PipelineElement &E);
+ Error parseCGSCCPass(CGSCCPassManager &CGPM, const PipelineElement &E);
+ Error parseFunctionPass(FunctionPassManager &FPM, const PipelineElement &E);
+ Error parseLoopPass(LoopPassManager &LPM, const PipelineElement &E);
bool parseAAPassName(AAManager &AA, StringRef Name);
Error parseLoopPassPipeline(LoopPassManager &LPM,
- ArrayRef<PipelineElement> Pipeline,
- bool DebugLogging);
+ ArrayRef<PipelineElement> Pipeline);
Error parseFunctionPassPipeline(FunctionPassManager &FPM,
- ArrayRef<PipelineElement> Pipeline,
- bool DebugLogging);
+ ArrayRef<PipelineElement> Pipeline);
Error parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
- ArrayRef<PipelineElement> Pipeline,
- bool DebugLogging);
+ ArrayRef<PipelineElement> Pipeline);
Error parseModulePassPipeline(ModulePassManager &MPM,
- ArrayRef<PipelineElement> Pipeline,
- bool DebugLogging);
+ ArrayRef<PipelineElement> Pipeline);
- void addPGOInstrPasses(ModulePassManager &MPM, bool DebugLogging,
- OptimizationLevel Level, bool RunProfileGen, bool IsCS,
- std::string ProfileFile,
+ void addPGOInstrPasses(ModulePassManager &MPM, OptimizationLevel Level,
+ bool RunProfileGen, bool IsCS, std::string ProfileFile,
std::string ProfileRemappingFile);
void invokePeepholeEPCallbacks(FunctionPassManager &, OptimizationLevel);
} // namespace
+PassBuilder::PassBuilder(bool DebugLogging, TargetMachine *TM,
+ PipelineTuningOptions PTO, Optional<PGOOptions> PGOOpt,
+ PassInstrumentationCallbacks *PIC)
+ : DebugLogging(DebugLogging), TM(TM), PTO(PTO), PGOOpt(PGOOpt), PIC(PIC) {
+ if (TM)
+ TM->registerPassBuilderCallbacks(*this, DebugLogging);
+}
+
void PassBuilder::invokePeepholeEPCallbacks(
FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) {
for (auto &C : PeepholeEPCallbacks)
}
// TODO: Investigate the cost/benefit of tail call elimination on debugging.
-FunctionPassManager PassBuilder::buildO1FunctionSimplificationPipeline(
- OptimizationLevel Level, ThinLTOPhase Phase, bool DebugLogging) {
+FunctionPassManager
+PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
+ ThinLTOPhase Phase) {
FunctionPassManager FPM(DebugLogging);
FunctionPassManager
PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
- ThinLTOPhase Phase,
- bool DebugLogging) {
+ ThinLTOPhase Phase) {
assert(Level != OptimizationLevel::O0 && "Must request optimizations!");
// The O1 pipeline has a separate pipeline creation function to simplify
// construction readability.
if (Level.getSpeedupLevel() == 1)
- return buildO1FunctionSimplificationPipeline(Level, Phase, DebugLogging);
+ return buildO1FunctionSimplificationPipeline(Level, Phase);
FunctionPassManager FPM(DebugLogging);
return FPM;
}
-void PassBuilder::addPGOInstrPasses(ModulePassManager &MPM, bool DebugLogging,
+void PassBuilder::addPGOInstrPasses(ModulePassManager &MPM,
PassBuilder::OptimizationLevel Level,
bool RunProfileGen, bool IsCS,
std::string ProfileFile,
}
void PassBuilder::addPGOInstrPassesForO0(ModulePassManager &MPM,
- bool DebugLogging, bool RunProfileGen,
- bool IsCS, std::string ProfileFile,
+ bool RunProfileGen, bool IsCS,
+ std::string ProfileFile,
std::string ProfileRemappingFile) {
if (!RunProfileGen) {
assert(!ProfileFile.empty() && "Profile use expecting a profile file!");
}
ModuleInlinerWrapperPass
-PassBuilder::buildInlinerPipeline(OptimizationLevel Level, ThinLTOPhase Phase,
- bool DebugLogging) {
+PassBuilder::buildInlinerPipeline(OptimizationLevel Level, ThinLTOPhase Phase) {
InlineParams IP = getInlineParamsFromOptLevel(Level);
if (Phase == PassBuilder::ThinLTOPhase::PreLink && PGOOpt &&
PGOOpt->Action == PGOOptions::SampleUse)
// Lastly, add the core function simplification pipeline nested inside the
// CGSCC walk.
MainCGPipeline.addPass(createCGSCCToFunctionPassAdaptor(
- buildFunctionSimplificationPipeline(Level, Phase, DebugLogging)));
+ buildFunctionSimplificationPipeline(Level, Phase)));
for (auto &C : CGSCCOptimizerLateEPCallbacks)
C(MainCGPipeline, Level);
return MIWP;
}
-ModulePassManager PassBuilder::buildModuleSimplificationPipeline(
- OptimizationLevel Level, ThinLTOPhase Phase, bool DebugLogging) {
+ModulePassManager
+PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
+ ThinLTOPhase Phase) {
ModulePassManager MPM(DebugLogging);
bool HasSampleProfile = PGOOpt && (PGOOpt->Action == PGOOptions::SampleUse);
if (PGOOpt && Phase != ThinLTOPhase::PostLink &&
(PGOOpt->Action == PGOOptions::IRInstr ||
PGOOpt->Action == PGOOptions::IRUse)) {
- addPGOInstrPasses(MPM, DebugLogging, Level,
+ addPGOInstrPasses(MPM, Level,
/* RunProfileGen */ PGOOpt->Action == PGOOptions::IRInstr,
/* IsCS */ false, PGOOpt->ProfileFile,
PGOOpt->ProfileRemappingFile);
if (EnableSyntheticCounts && !PGOOpt)
MPM.addPass(SyntheticCountsPropagation());
- MPM.addPass(buildInlinerPipeline(Level, Phase, DebugLogging));
+ MPM.addPass(buildInlinerPipeline(Level, Phase));
if (EnableMemProfiler && Phase != ThinLTOPhase::PreLink) {
MPM.addPass(createModuleToFunctionPassAdaptor(MemProfilerPass()));
return MPM;
}
-ModulePassManager PassBuilder::buildModuleOptimizationPipeline(
- OptimizationLevel Level, bool DebugLogging, bool LTOPreLink) {
+ModulePassManager
+PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
+ bool LTOPreLink) {
ModulePassManager MPM(DebugLogging);
// Optimize globals now that the module is fully simplified.
// instrumentation is after all the inlines are done.
if (!LTOPreLink && PGOOpt) {
if (PGOOpt->CSAction == PGOOptions::CSIRInstr)
- addPGOInstrPasses(MPM, DebugLogging, Level, /* RunProfileGen */ true,
+ addPGOInstrPasses(MPM, Level, /* RunProfileGen */ true,
/* IsCS */ true, PGOOpt->CSProfileGenFile,
PGOOpt->ProfileRemappingFile);
else if (PGOOpt->CSAction == PGOOptions::CSIRUse)
- addPGOInstrPasses(MPM, DebugLogging, Level, /* RunProfileGen */ false,
+ addPGOInstrPasses(MPM, Level, /* RunProfileGen */ false,
/* IsCS */ true, PGOOpt->ProfileFile,
PGOOpt->ProfileRemappingFile);
}
ModulePassManager
PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
- bool DebugLogging, bool LTOPreLink) {
+ bool LTOPreLink) {
assert(Level != OptimizationLevel::O0 &&
"Must request optimizations for the default pipeline!");
MPM.addPass(createModuleToFunctionPassAdaptor(AddDiscriminatorsPass()));
// Add the core simplification pipeline.
- MPM.addPass(buildModuleSimplificationPipeline(Level, ThinLTOPhase::None,
- DebugLogging));
+ MPM.addPass(buildModuleSimplificationPipeline(Level, ThinLTOPhase::None));
// Now add the optimization pipeline.
- MPM.addPass(buildModuleOptimizationPipeline(Level, DebugLogging, LTOPreLink));
+ MPM.addPass(buildModuleOptimizationPipeline(Level, LTOPreLink));
return MPM;
}
ModulePassManager
-PassBuilder::buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level,
- bool DebugLogging) {
+PassBuilder::buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level) {
assert(Level != OptimizationLevel::O0 &&
"Must request optimizations for the default pipeline!");
// If we are planning to perform ThinLTO later, we don't bloat the code with
// unrolling/vectorization/... now. Just simplify the module as much as we
// can.
- MPM.addPass(buildModuleSimplificationPipeline(Level, ThinLTOPhase::PreLink,
- DebugLogging));
+ MPM.addPass(buildModuleSimplificationPipeline(Level, ThinLTOPhase::PreLink));
// Run partial inlining pass to partially inline functions that have
// large bodies.
}
ModulePassManager PassBuilder::buildThinLTODefaultPipeline(
- OptimizationLevel Level, bool DebugLogging,
- const ModuleSummaryIndex *ImportSummary) {
+ OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary) {
ModulePassManager MPM(DebugLogging);
if (ImportSummary) {
MPM.addPass(ForceFunctionAttrsPass());
// Add the core simplification pipeline.
- MPM.addPass(buildModuleSimplificationPipeline(Level, ThinLTOPhase::PostLink,
- DebugLogging));
+ MPM.addPass(buildModuleSimplificationPipeline(Level, ThinLTOPhase::PostLink));
// Now add the optimization pipeline.
- MPM.addPass(buildModuleOptimizationPipeline(Level, DebugLogging));
+ MPM.addPass(buildModuleOptimizationPipeline(Level));
return MPM;
}
ModulePassManager
-PassBuilder::buildLTOPreLinkDefaultPipeline(OptimizationLevel Level,
- bool DebugLogging) {
+PassBuilder::buildLTOPreLinkDefaultPipeline(OptimizationLevel Level) {
assert(Level != OptimizationLevel::O0 &&
"Must request optimizations for the default pipeline!");
// FIXME: We should use a customized pre-link pipeline!
- return buildPerModuleDefaultPipeline(Level, DebugLogging,
+ return buildPerModuleDefaultPipeline(Level,
/* LTOPreLink */ true);
}
ModulePassManager
-PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level, bool DebugLogging,
+PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
ModuleSummaryIndex *ExportSummary) {
ModulePassManager MPM(DebugLogging);
// sensitive PGO pass.
if (PGOOpt) {
if (PGOOpt->CSAction == PGOOptions::CSIRInstr)
- addPGOInstrPasses(MPM, DebugLogging, Level, /* RunProfileGen */ true,
+ addPGOInstrPasses(MPM, Level, /* RunProfileGen */ true,
/* IsCS */ true, PGOOpt->CSProfileGenFile,
PGOOpt->ProfileRemappingFile);
else if (PGOOpt->CSAction == PGOOptions::CSIRUse)
- addPGOInstrPasses(MPM, DebugLogging, Level, /* RunProfileGen */ false,
+ addPGOInstrPasses(MPM, Level, /* RunProfileGen */ false,
/* IsCS */ true, PGOOpt->ProfileFile,
PGOOpt->ProfileRemappingFile);
}
}
Error PassBuilder::parseModulePass(ModulePassManager &MPM,
- const PipelineElement &E,
- bool DebugLogging) {
+ const PipelineElement &E) {
auto &Name = E.Name;
auto &InnerPipeline = E.InnerPipeline;
if (!InnerPipeline.empty()) {
if (Name == "module") {
ModulePassManager NestedMPM(DebugLogging);
- if (auto Err =
- parseModulePassPipeline(NestedMPM, InnerPipeline, DebugLogging))
+ if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
return Err;
MPM.addPass(std::move(NestedMPM));
return Error::success();
}
if (Name == "cgscc") {
CGSCCPassManager CGPM(DebugLogging);
- if (auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline, DebugLogging))
+ if (auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
return Err;
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
return Error::success();
}
if (Name == "function") {
FunctionPassManager FPM(DebugLogging);
- if (auto Err =
- parseFunctionPassPipeline(FPM, InnerPipeline, DebugLogging))
+ if (auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
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, DebugLogging))
+ if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
return Err;
MPM.addPass(createRepeatedPass(*Count, std::move(NestedMPM)));
return Error::success();
(PGOOpt->Action == PGOOptions::IRInstr ||
PGOOpt->Action == PGOOptions::IRUse))
addPGOInstrPassesForO0(
- MPM, DebugLogging,
+ MPM,
/* RunProfileGen */ (PGOOpt->Action == PGOOptions::IRInstr),
/* IsCS */ false, PGOOpt->ProfileFile,
PGOOpt->ProfileRemappingFile);
L.getSpeedupLevel() > 1 && L != OptimizationLevel::Oz;
if (Matches[1] == "default") {
- MPM.addPass(buildPerModuleDefaultPipeline(L, DebugLogging));
+ MPM.addPass(buildPerModuleDefaultPipeline(L));
} else if (Matches[1] == "thinlto-pre-link") {
- MPM.addPass(buildThinLTOPreLinkDefaultPipeline(L, DebugLogging));
+ MPM.addPass(buildThinLTOPreLinkDefaultPipeline(L));
} else if (Matches[1] == "thinlto") {
- MPM.addPass(buildThinLTODefaultPipeline(L, DebugLogging, nullptr));
+ MPM.addPass(buildThinLTODefaultPipeline(L, nullptr));
} else if (Matches[1] == "lto-pre-link") {
- MPM.addPass(buildLTOPreLinkDefaultPipeline(L, DebugLogging));
+ MPM.addPass(buildLTOPreLinkDefaultPipeline(L));
} else {
assert(Matches[1] == "lto" && "Not one of the matched options!");
- MPM.addPass(buildLTODefaultPipeline(L, DebugLogging, nullptr));
+ MPM.addPass(buildLTODefaultPipeline(L, nullptr));
}
return Error::success();
}
}
Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM,
- const PipelineElement &E, bool DebugLogging) {
+ const PipelineElement &E) {
auto &Name = E.Name;
auto &InnerPipeline = E.InnerPipeline;
if (!InnerPipeline.empty()) {
if (Name == "cgscc") {
CGSCCPassManager NestedCGPM(DebugLogging);
- if (auto Err =
- parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, DebugLogging))
+ if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
return Err;
// Add the nested pass manager with the appropriate adaptor.
CGPM.addPass(std::move(NestedCGPM));
}
if (Name == "function") {
FunctionPassManager FPM(DebugLogging);
- if (auto Err =
- parseFunctionPassPipeline(FPM, InnerPipeline, DebugLogging))
+ if (auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
return Err;
// Add the nested pass manager with the appropriate adaptor.
CGPM.addPass(createCGSCCToFunctionPassAdaptor(std::move(FPM)));
}
if (auto Count = parseRepeatPassName(Name)) {
CGSCCPassManager NestedCGPM(DebugLogging);
- if (auto Err =
- parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, DebugLogging))
+ if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
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, DebugLogging))
+ if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
return Err;
CGPM.addPass(
createDevirtSCCRepeatedPass(std::move(NestedCGPM), *MaxRepetitions));
}
Error PassBuilder::parseFunctionPass(FunctionPassManager &FPM,
- const PipelineElement &E,
- bool DebugLogging) {
+ const PipelineElement &E) {
auto &Name = E.Name;
auto &InnerPipeline = E.InnerPipeline;
if (!InnerPipeline.empty()) {
if (Name == "function") {
FunctionPassManager NestedFPM(DebugLogging);
- if (auto Err =
- parseFunctionPassPipeline(NestedFPM, InnerPipeline, DebugLogging))
+ if (auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
return Err;
// Add the nested pass manager with the appropriate adaptor.
FPM.addPass(std::move(NestedFPM));
}
if (Name == "loop" || Name == "loop-mssa") {
LoopPassManager LPM(DebugLogging);
- if (auto Err = parseLoopPassPipeline(LPM, InnerPipeline, DebugLogging))
+ if (auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
return Err;
// Add the nested pass manager with the appropriate adaptor.
bool UseMemorySSA = (Name == "loop-mssa");
}
if (auto Count = parseRepeatPassName(Name)) {
FunctionPassManager NestedFPM(DebugLogging);
- if (auto Err =
- parseFunctionPassPipeline(NestedFPM, InnerPipeline, DebugLogging))
+ if (auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
return Err;
FPM.addPass(createRepeatedPass(*Count, std::move(NestedFPM)));
return Error::success();
inconvertibleErrorCode());
}
-Error PassBuilder::parseLoopPass(LoopPassManager &LPM, const PipelineElement &E,
- bool DebugLogging) {
+Error PassBuilder::parseLoopPass(LoopPassManager &LPM,
+ const PipelineElement &E) {
StringRef Name = E.Name;
auto &InnerPipeline = E.InnerPipeline;
if (!InnerPipeline.empty()) {
if (Name == "loop") {
LoopPassManager NestedLPM(DebugLogging);
- if (auto Err =
- parseLoopPassPipeline(NestedLPM, InnerPipeline, DebugLogging))
+ if (auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
return Err;
// Add the nested pass manager with the appropriate adaptor.
LPM.addPass(std::move(NestedLPM));
}
if (auto Count = parseRepeatPassName(Name)) {
LoopPassManager NestedLPM(DebugLogging);
- if (auto Err =
- parseLoopPassPipeline(NestedLPM, InnerPipeline, DebugLogging))
+ if (auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
return Err;
LPM.addPass(createRepeatedPass(*Count, std::move(NestedLPM)));
return Error::success();
}
Error PassBuilder::parseLoopPassPipeline(LoopPassManager &LPM,
- ArrayRef<PipelineElement> Pipeline,
- bool DebugLogging) {
+ ArrayRef<PipelineElement> Pipeline) {
for (const auto &Element : Pipeline) {
- if (auto Err = parseLoopPass(LPM, Element, DebugLogging))
+ if (auto Err = parseLoopPass(LPM, Element))
return Err;
}
return Error::success();
}
-Error PassBuilder::parseFunctionPassPipeline(FunctionPassManager &FPM,
- ArrayRef<PipelineElement> Pipeline,
- bool DebugLogging) {
+Error PassBuilder::parseFunctionPassPipeline(
+ FunctionPassManager &FPM, ArrayRef<PipelineElement> Pipeline) {
for (const auto &Element : Pipeline) {
- if (auto Err = parseFunctionPass(FPM, Element, DebugLogging))
+ if (auto Err = parseFunctionPass(FPM, Element))
return Err;
}
return Error::success();
}
Error PassBuilder::parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
- ArrayRef<PipelineElement> Pipeline,
- bool DebugLogging) {
+ ArrayRef<PipelineElement> Pipeline) {
for (const auto &Element : Pipeline) {
- if (auto Err = parseCGSCCPass(CGPM, Element, DebugLogging))
+ if (auto Err = parseCGSCCPass(CGPM, Element))
return Err;
}
return Error::success();
}
Error PassBuilder::parseModulePassPipeline(ModulePassManager &MPM,
- ArrayRef<PipelineElement> Pipeline,
- bool DebugLogging) {
+ ArrayRef<PipelineElement> Pipeline) {
for (const auto &Element : Pipeline) {
- if (auto Err = parseModulePass(MPM, Element, DebugLogging))
+ if (auto Err = parseModulePass(MPM, Element))
return Err;
}
return Error::success();
// 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 DebugLogging) {
+ StringRef PipelineText) {
auto Pipeline = parsePipelineText(PipelineText);
if (!Pipeline || Pipeline->empty())
return make_error<StringError>(
}
}
- if (auto Err = parseModulePassPipeline(MPM, *Pipeline, DebugLogging))
+ if (auto Err = parseModulePassPipeline(MPM, *Pipeline))
return Err;
return Error::success();
}
// Primary pass pipeline description parsing routine for a \c CGSCCPassManager
Error PassBuilder::parsePassPipeline(CGSCCPassManager &CGPM,
- StringRef PipelineText,
- bool DebugLogging) {
+ StringRef PipelineText) {
auto Pipeline = parsePipelineText(PipelineText);
if (!Pipeline || Pipeline->empty())
return make_error<StringError>(
.str(),
inconvertibleErrorCode());
- if (auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline, DebugLogging))
+ if (auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
return Err;
return Error::success();
}
// Primary pass pipeline description parsing routine for a \c
// FunctionPassManager
Error PassBuilder::parsePassPipeline(FunctionPassManager &FPM,
- StringRef PipelineText,
- bool DebugLogging) {
+ StringRef PipelineText) {
auto Pipeline = parsePipelineText(PipelineText);
if (!Pipeline || Pipeline->empty())
return make_error<StringError>(
.str(),
inconvertibleErrorCode());
- if (auto Err = parseFunctionPassPipeline(FPM, *Pipeline, DebugLogging))
+ if (auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
return Err;
return Error::success();
}
// Primary pass pipeline description parsing routine for a \c LoopPassManager
Error PassBuilder::parsePassPipeline(LoopPassManager &CGPM,
- StringRef PipelineText,
- bool DebugLogging) {
+ StringRef PipelineText) {
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, DebugLogging))
+ if (auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
return Err;
return Error::success();
/// 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 DebugLogging) {
+static void registerEPCallbacks(PassBuilder &PB) {
if (tryParsePipelineText<FunctionPassManager>(PB, PeepholeEPPipeline))
PB.registerPeepholeEPCallback(
- [&PB, DebugLogging](FunctionPassManager &PM,
- PassBuilder::OptimizationLevel Level) {
+ [&PB](FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
ExitOnError Err("Unable to parse PeepholeEP pipeline: ");
- Err(PB.parsePassPipeline(PM, PeepholeEPPipeline, DebugLogging));
+ Err(PB.parsePassPipeline(PM, PeepholeEPPipeline));
});
if (tryParsePipelineText<LoopPassManager>(PB,
LateLoopOptimizationsEPPipeline))
PB.registerLateLoopOptimizationsEPCallback(
- [&PB, DebugLogging](LoopPassManager &PM,
- PassBuilder::OptimizationLevel Level) {
+ [&PB](LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
ExitOnError Err("Unable to parse LateLoopOptimizationsEP pipeline: ");
- Err(PB.parsePassPipeline(PM, LateLoopOptimizationsEPPipeline,
- DebugLogging));
+ Err(PB.parsePassPipeline(PM, LateLoopOptimizationsEPPipeline));
});
if (tryParsePipelineText<LoopPassManager>(PB, LoopOptimizerEndEPPipeline))
PB.registerLoopOptimizerEndEPCallback(
- [&PB, DebugLogging](LoopPassManager &PM,
- PassBuilder::OptimizationLevel Level) {
+ [&PB](LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
ExitOnError Err("Unable to parse LoopOptimizerEndEP pipeline: ");
- Err(PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline,
- DebugLogging));
+ Err(PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline));
});
if (tryParsePipelineText<FunctionPassManager>(PB,
ScalarOptimizerLateEPPipeline))
PB.registerScalarOptimizerLateEPCallback(
- [&PB, DebugLogging](FunctionPassManager &PM,
- PassBuilder::OptimizationLevel Level) {
+ [&PB](FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
ExitOnError Err("Unable to parse ScalarOptimizerLateEP pipeline: ");
- Err(PB.parsePassPipeline(PM, ScalarOptimizerLateEPPipeline,
- DebugLogging));
+ Err(PB.parsePassPipeline(PM, ScalarOptimizerLateEPPipeline));
});
if (tryParsePipelineText<CGSCCPassManager>(PB, CGSCCOptimizerLateEPPipeline))
PB.registerCGSCCOptimizerLateEPCallback(
- [&PB, DebugLogging](CGSCCPassManager &PM,
- PassBuilder::OptimizationLevel Level) {
+ [&PB](CGSCCPassManager &PM, PassBuilder::OptimizationLevel Level) {
ExitOnError Err("Unable to parse CGSCCOptimizerLateEP pipeline: ");
- Err(PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline,
- DebugLogging));
+ Err(PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline));
});
if (tryParsePipelineText<FunctionPassManager>(PB, VectorizerStartEPPipeline))
PB.registerVectorizerStartEPCallback(
- [&PB, DebugLogging](FunctionPassManager &PM,
- PassBuilder::OptimizationLevel Level) {
+ [&PB](FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
ExitOnError Err("Unable to parse VectorizerStartEP pipeline: ");
- Err(PB.parsePassPipeline(PM, VectorizerStartEPPipeline,
- DebugLogging));
+ Err(PB.parsePassPipeline(PM, VectorizerStartEPPipeline));
});
if (tryParsePipelineText<ModulePassManager>(PB, PipelineStartEPPipeline))
- PB.registerPipelineStartEPCallback(
- [&PB, DebugLogging](ModulePassManager &PM) {
- ExitOnError Err("Unable to parse PipelineStartEP pipeline: ");
- Err(PB.parsePassPipeline(PM, PipelineStartEPPipeline, DebugLogging));
- });
+ PB.registerPipelineStartEPCallback([&PB](ModulePassManager &PM) {
+ ExitOnError Err("Unable to parse PipelineStartEP pipeline: ");
+ Err(PB.parsePassPipeline(PM, PipelineStartEPPipeline));
+ });
if (tryParsePipelineText<FunctionPassManager>(PB, OptimizerLastEPPipeline))
PB.registerOptimizerLastEPCallback(
- [&PB, DebugLogging](ModulePassManager &PM,
- PassBuilder::OptimizationLevel) {
+ [&PB](ModulePassManager &PM, PassBuilder::OptimizationLevel) {
ExitOnError Err("Unable to parse OptimizerLastEP pipeline: ");
- Err(PB.parsePassPipeline(PM, OptimizerLastEPPipeline, DebugLogging));
+ Err(PB.parsePassPipeline(PM, OptimizerLastEPPipeline));
});
}
// option has been enabled.
PTO.LoopUnrolling = !DisableLoopUnrolling;
PTO.Coroutines = Coroutines;
- PassBuilder PB(TM, PTO, P, &PIC);
- registerEPCallbacks(PB, DebugPM);
+ PassBuilder PB(DebugPM, TM, PTO, P, &PIC);
+ registerEPCallbacks(PB);
// Load requested pass plugins and let them register pass builder callbacks
for (auto &PluginFN : PassPlugins) {
PB.registerLoopAnalyses(LAM);
PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
- if (TM)
- TM->registerPassBuilderCallbacks(PB, DebugPM);
-
ModulePassManager MPM(DebugPM);
if (VK > VK_NoVerifier)
MPM.addPass(VerifierPass());
if (!PassPipeline.empty()) {
assert(Passes.empty() &&
"PassPipeline and Passes should not both contain passes");
- if (auto Err = PB.parsePassPipeline(MPM, PassPipeline, DebugPM)) {
+ if (auto Err = PB.parsePassPipeline(MPM, PassPipeline)) {
errs() << Arg0 << ": " << toString(std::move(Err)) << "\n";
return false;
}
std::string ModifiedPassName(PassName.begin(), PassName.end());
if (PB.isAnalysisPassName(PassName))
ModifiedPassName = "require<" + ModifiedPassName + ">";
- if (auto Err = PB.parsePassPipeline(MPM, ModifiedPassName, DebugPM)) {
+ if (auto Err = PB.parsePassPipeline(MPM, ModifiedPassName)) {
errs() << Arg0 << ": " << toString(std::move(Err)) << "\n";
return false;
}