Author: Joseph Huber Date: 2022-03-22T09:28:45-04:00 New Revision: 5856f30b5ae06153ff4a7d3db73ff8d9a05b4144
URL: https://github.com/llvm/llvm-project/commit/5856f30b5ae06153ff4a7d3db73ff8d9a05b4144 DIFF: https://github.com/llvm/llvm-project/commit/5856f30b5ae06153ff4a7d3db73ff8d9a05b4144.diff LOG: [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 Added: Modified: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp llvm/include/llvm/LTO/Config.h llvm/lib/LTO/LTOBackend.cpp Removed: ################################################################################ diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index a64648e6fe155..e9f616653d33e 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -860,6 +860,7 @@ std::unique_ptr<lto::LTO> createLTO( // TODO: Handle index-only thin-LTO Backend = lto::createInProcessThinBackend( llvm::heavyweight_hardware_concurrency(1)); + Conf.UseDefaultPipeline = true; Conf.CPU = Arch.str(); Conf.Options = codegen::InitTargetOptionsFromCodeGenFlags(TheTriple); diff --git a/llvm/include/llvm/LTO/Config.h b/llvm/include/llvm/LTO/Config.h index eb793d62907e2..0cf84de7b9f87 100644 --- a/llvm/include/llvm/LTO/Config.h +++ b/llvm/include/llvm/LTO/Config.h @@ -60,6 +60,9 @@ struct Config { /// Use the new pass manager bool UseNewPM = LLVM_ENABLE_NEW_PASS_MANAGER; + /// Use the standard optimization pipeline. + bool UseDefaultPipeline = false; + /// Flag to indicate that the optimizer should not assume builtins are present /// on the target. bool Freestanding = false; diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index 3877def53c3f1..91807b151eb9e 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -298,6 +298,8 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM, report_fatal_error(Twine("unable to parse pass pipeline description '") + Conf.OptPipeline + "': " + toString(std::move(Err))); } + } else if (Conf.UseDefaultPipeline) { + MPM.addPass(PB.buildPerModuleDefaultPipeline(OL)); } else if (IsThinLTO) { MPM.addPass(PB.buildThinLTODefaultPipeline(OL, ImportSummary)); } else { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits