[llvm-branch-commits] [llvm] 9833a55 - [OpenMP] Run an extra 'OpenMPOpt' pass in LTO-mode
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Jan 27 20:45:18 PST 2023
Author: Joseph Huber
Date: 2023-01-27T20:44:34-08:00
New Revision: 9833a552e36c3a9fb6491d00a2b22830fad91bef
URL: https://github.com/llvm/llvm-project/commit/9833a552e36c3a9fb6491d00a2b22830fad91bef
DIFF: https://github.com/llvm/llvm-project/commit/9833a552e36c3a9fb6491d00a2b22830fad91bef.diff
LOG: [OpenMP] Run an extra 'OpenMPOpt' pass in LTO-mode
The `OpenMPOpt` pass is pivotal to the performance of many OpenMP
offloading programs. When we perform non-LTO builds with OpenMP we used
to link the OpenMP deviceRTL individually for each TU. This lead to us
getting an additional attributor run on the combined runtime and user
code. When we used LTO we lost a run and suffered a large performance
degradation. This patch simply adds in the extra `OpenMPOpt` pass that
we miss into the LTO pipeline. This patch fixes the performance
regression shown in applications that used OpenMP offloading in LTO
mode.
Previously, this wasn't legal to do as we could emit new runtime calls
into the module. That was fixed by D142646.
Depends on D142646
Fixes https://github.com/llvm/llvm-project/issues/60300
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D142650
(cherry picked from commit 6185246f4f62345d0cfdaef62da7e15b01d52557)
Added:
Modified:
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
llvm/lib/Passes/PassBuilderPipelines.cpp
llvm/test/Other/new-pm-lto-defaults.ll
Removed:
################################################################################
diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 587e7f3043ded..361179ad8a3b2 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -513,8 +513,6 @@ std::unique_ptr<lto::LTO> createLTO(
assert(CGOptLevelOrNone && "Invalid optimization level");
Conf.CGOptLevel = *CGOptLevelOrNone;
Conf.OptLevel = OptLevel[1] - '0';
- if (Conf.OptLevel > 0)
- Conf.UseDefaultPipeline = true;
Conf.DefaultTriple = Triple.getTriple();
LTOError = false;
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 0762c535f7f58..75b34b81b5fed 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -1712,6 +1712,9 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
// Optimize globals again after we ran the inliner.
MPM.addPass(GlobalOptPass());
+ // Run the OpenMPOpt pass again after global optimizations.
+ MPM.addPass(OpenMPOptPass(ThinOrFullLTOPhase::FullLTOPostLink));
+
// Garbage collect dead functions.
MPM.addPass(GlobalDCEPass());
diff --git a/llvm/test/Other/new-pm-lto-defaults.ll b/llvm/test/Other/new-pm-lto-defaults.ll
index e7b054b6311ed..55b4ad0526a0a 100644
--- a/llvm/test/Other/new-pm-lto-defaults.ll
+++ b/llvm/test/Other/new-pm-lto-defaults.ll
@@ -78,6 +78,7 @@
; CHECK-O23SZ-NEXT: Running pass: InlinerPass
; CHECK-O23SZ-NEXT: Invalidating analysis: InlineAdvisorAnalysis
; CHECK-O23SZ-NEXT: Running pass: GlobalOptPass
+; CHECK-O23SZ-NEXT: Running pass: OpenMPOptPass
; CHECK-O23SZ-NEXT: Running pass: GlobalDCEPass
; CHECK-O23SZ-NEXT: Running pass: ArgumentPromotionPass
; CHECK-O23SZ-NEXT: Running pass: DeadArgumentEliminationPass
More information about the llvm-branch-commits
mailing list