Skip to content

Commit 8245ec3

Browse files
bors[bot]vext01
andauthored
80: Add the ability to customise the pre-link pipeline r=ltratt a=vext01 Co-authored-by: Edd Barrett <[email protected]>
2 parents 29f8990 + 93a4ea9 commit 8245ec3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

clang/lib/CodeGen/BackendUtil.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ static cl::opt<bool> ClSanitizeOnOptimizerEarlyEP(
109109
cl::desc("Insert sanitizers on OptimizerEarlyEP."), cl::init(false));
110110
}
111111

112+
static cl::opt<std::string> NewPMPasses("newpm-passes", cl::Optional,
113+
cl::desc("Specify a custom pre-link pipeline. An empty string specifies the default pipeline."),
114+
cl::init(""));
115+
112116
namespace {
113117

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

997-
if (CodeGenOpts.OptimizationLevel == 0) {
1001+
if (!NewPMPasses.empty()) {
1002+
MPM = PB.buildO0DefaultPipeline(Level, IsLTO || IsThinLTO);
1003+
if (auto Err = PB.parsePassPipeline(MPM, NewPMPasses)) {
1004+
report_fatal_error(Twine("unable to parse pass pipeline description '") +
1005+
NewPMPasses + "': " + toString(std::move(Err)));
1006+
}
1007+
} else if (CodeGenOpts.OptimizationLevel == 0) {
9981008
MPM = PB.buildO0DefaultPipeline(Level, IsLTO || IsThinLTO);
9991009
} else if (IsThinLTO) {
10001010
MPM = PB.buildThinLTOPreLinkDefaultPipeline(Level);

0 commit comments

Comments
 (0)