Skip to content

Commit

Permalink
Merge rust-lang#80
Browse files Browse the repository at this point in the history
80: Add the ability to customise the pre-link pipeline r=ltratt a=vext01



Co-authored-by: Edd Barrett <[email protected]>
  • Loading branch information
bors[bot] and vext01 authored Sep 20, 2023
2 parents 29f8990 + 93a4ea9 commit 8245ec3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ static cl::opt<bool> ClSanitizeOnOptimizerEarlyEP(
cl::desc("Insert sanitizers on OptimizerEarlyEP."), cl::init(false));
}

static cl::opt<std::string> NewPMPasses("newpm-passes", cl::Optional,
cl::desc("Specify a custom pre-link pipeline. An empty string specifies the default pipeline."),
cl::init(""));

namespace {

// Default filename used for profile generation.
Expand Down Expand Up @@ -994,7 +998,13 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
MPM.addPass(InstrProfiling(*Options, false));
});

if (CodeGenOpts.OptimizationLevel == 0) {
if (!NewPMPasses.empty()) {
MPM = PB.buildO0DefaultPipeline(Level, IsLTO || IsThinLTO);
if (auto Err = PB.parsePassPipeline(MPM, NewPMPasses)) {
report_fatal_error(Twine("unable to parse pass pipeline description '") +
NewPMPasses + "': " + toString(std::move(Err)));
}
} else if (CodeGenOpts.OptimizationLevel == 0) {
MPM = PB.buildO0DefaultPipeline(Level, IsLTO || IsThinLTO);
} else if (IsThinLTO) {
MPM = PB.buildThinLTOPreLinkDefaultPipeline(Level);
Expand Down

0 comments on commit 8245ec3

Please sign in to comment.