mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-08 03:46:02 +03:00
Add indirect call promotion pass when PGO info is available. (#2156)
This pass was apparently implicit in LLVM < 5.0. Fixes test PGO/indirect_calls.d with LLVM 5.0.
This commit is contained in:
parent
40de53d095
commit
058d574f6b
1 changed files with 12 additions and 2 deletions
|
@ -212,9 +212,11 @@ static void addThreadSanitizerPass(const PassManagerBuilder &Builder,
|
|||
PM.add(createThreadSanitizerPass());
|
||||
}
|
||||
|
||||
static void addInstrProfilingPass(legacy::PassManagerBase &mpm) {
|
||||
// Adds PGO instrumentation generation and use passes.
|
||||
static void addPGOPasses(legacy::PassManagerBase &mpm, unsigned optLevel) {
|
||||
#if LDC_WITH_PGO
|
||||
if (global.params.genInstrProf) {
|
||||
// We are generating PGO instrumented code.
|
||||
InstrProfOptions options;
|
||||
options.NoRedZone = global.params.disableRedZone;
|
||||
if (global.params.datafileInstrProf)
|
||||
|
@ -223,6 +225,14 @@ static void addInstrProfilingPass(legacy::PassManagerBase &mpm) {
|
|||
mpm.add(createInstrProfilingLegacyPass(options));
|
||||
#else
|
||||
mpm.add(createInstrProfilingPass(options));
|
||||
#endif
|
||||
} else if (global.params.datafileInstrProf) {
|
||||
// We are generating code with PGO profile information available.
|
||||
#if LDC_LLVM_VER >= 500
|
||||
// Do indirect call promotion from -O1
|
||||
if (optLevel > 0) {
|
||||
mpm.add(createPGOIndirectCallPromotionLegacyPass());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@ -325,7 +335,7 @@ static void addOptimizationPasses(PassManagerBase &mpm,
|
|||
builder.addExtension(PassManagerBuilder::EP_OptimizerLast,
|
||||
addStripExternalsPass);
|
||||
|
||||
addInstrProfilingPass(mpm);
|
||||
addPGOPasses(mpm, optLevel);
|
||||
|
||||
builder.populateFunctionPassManager(fpm);
|
||||
builder.populateModulePassManager(mpm);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue