Skip to content

Commit 5856f30

Browse files
committed
[LTO] Add configuartion option to use default optimization pipeline
This patch adds a configuration option to simply use the default pass pipeline in favor of the LTO-specific one. We observed some severe performance penalties when uding device-side LTO for OpenMP offloading applications caused by the LTO-pass pipeline. This is primarily because OpenMP uses an LLVM bitcode library to implement a GPU runtime library. In a standard compilation we link this bitcode library into each source file and optimize it with the default pipeline. When performing LTO we link it late with all the files, but the bitcode library never has the regular optimization pipeline applied to it so we miss a few optimizations just using the LTO pipeline to optimize it. I'm not committed to this solution, but it's the easiest method to solve this performance regression when using LTO without changing the optimizatin pipeline for other users. Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D122133
1 parent b68e78c commit 5856f30

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ std::unique_ptr<lto::LTO> createLTO(
860860
// TODO: Handle index-only thin-LTO
861861
Backend = lto::createInProcessThinBackend(
862862
llvm::heavyweight_hardware_concurrency(1));
863+
Conf.UseDefaultPipeline = true;
863864

864865
Conf.CPU = Arch.str();
865866
Conf.Options = codegen::InitTargetOptionsFromCodeGenFlags(TheTriple);

llvm/include/llvm/LTO/Config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ struct Config {
6060
/// Use the new pass manager
6161
bool UseNewPM = LLVM_ENABLE_NEW_PASS_MANAGER;
6262

63+
/// Use the standard optimization pipeline.
64+
bool UseDefaultPipeline = false;
65+
6366
/// Flag to indicate that the optimizer should not assume builtins are present
6467
/// on the target.
6568
bool Freestanding = false;

llvm/lib/LTO/LTOBackend.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM,
298298
report_fatal_error(Twine("unable to parse pass pipeline description '") +
299299
Conf.OptPipeline + "': " + toString(std::move(Err)));
300300
}
301+
} else if (Conf.UseDefaultPipeline) {
302+
MPM.addPass(PB.buildPerModuleDefaultPipeline(OL));
301303
} else if (IsThinLTO) {
302304
MPM.addPass(PB.buildThinLTODefaultPipeline(OL, ImportSummary));
303305
} else {

0 commit comments

Comments
 (0)