Skip to content

[Pipelines][Coroutines] Tune coroutine passes only for ThinLTO pre-link pipeline #90690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2024

Conversation

apolloww
Copy link
Contributor

@apolloww apolloww commented Apr 30, 2024

Follow up to #90310, limit the tune up only to ThinLTO pre-link as coroutine passes are not in MonoLTO backend

@llvmbot llvmbot added clang Clang issues not falling into any other category coroutines C++20 coroutines labels Apr 30, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 30, 2024

@llvm/pr-subscribers-coroutines

@llvm/pr-subscribers-clang

Author: Wei Wang (apolloww)

Changes

Follow up to #90310, limit the tune up only to ThinLTO pre-link as coroutine passes are not in MonoLTO backend

Also coro-elide-thinlto test is still failing on some Buildbots, only run the test under x86_64 linux target.


Full diff: https://github.com/llvm/llvm-project/pull/90690.diff

3 Files Affected:

  • (modified) clang/test/CodeGenCoroutines/coro-elide-thinlto.cpp (+1)
  • (modified) llvm/lib/Passes/PassBuilderPipelines.cpp (+3-3)
  • (modified) llvm/test/Other/new-pm-defaults.ll (+2-4)
diff --git a/clang/test/CodeGenCoroutines/coro-elide-thinlto.cpp b/clang/test/CodeGenCoroutines/coro-elide-thinlto.cpp
index d0e60e67963dfd..5b2d0146578437 100644
--- a/clang/test/CodeGenCoroutines/coro-elide-thinlto.cpp
+++ b/clang/test/CodeGenCoroutines/coro-elide-thinlto.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86_64-linux
 // This tests that the coroutine elide optimization could happen succesfully with ThinLTO.
 // This test is adapted from coro-elide.cpp and splits functions into two files.
 //
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 594549034cc829..100889c0845bc3 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -963,7 +963,7 @@ PassBuilder::buildInlinerPipeline(OptimizationLevel Level,
   MainCGPipeline.addPass(createCGSCCToFunctionPassAdaptor(
       RequireAnalysisPass<ShouldNotRunFunctionPassesAnalysis, Function>()));
 
-  if (!isLTOPreLink(Phase))
+  if (Phase != ThinOrFullLTOPhase::ThinLTOPreLink)
     MainCGPipeline.addPass(CoroSplitPass(Level != OptimizationLevel::O0));
 
   // Make sure we don't affect potential future NoRerun CGSCC adaptors.
@@ -1006,7 +1006,7 @@ PassBuilder::buildModuleInlinerPipeline(OptimizationLevel Level,
       buildFunctionSimplificationPipeline(Level, Phase),
       PTO.EagerlyInvalidateAnalyses));
 
-  if (!isLTOPreLink(Phase))
+  if (Phase != ThinOrFullLTOPhase::ThinLTOPreLink)
     MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(
         CoroSplitPass(Level != OptimizationLevel::O0)));
 
@@ -1185,7 +1185,7 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
   // and argument promotion.
   MPM.addPass(DeadArgumentEliminationPass());
 
-  if (!isLTOPreLink(Phase))
+  if (Phase != ThinOrFullLTOPhase::ThinLTOPreLink)
     MPM.addPass(CoroCleanupPass());
 
   // Optimize globals now that functions are fully simplified.
diff --git a/llvm/test/Other/new-pm-defaults.ll b/llvm/test/Other/new-pm-defaults.ll
index ebfed7b687e2ce..51fb93daa4dfa6 100644
--- a/llvm/test/Other/new-pm-defaults.ll
+++ b/llvm/test/Other/new-pm-defaults.ll
@@ -224,14 +224,12 @@
 ; CHECK-O-NEXT: Running pass: PostOrderFunctionAttrsPass
 ; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}ShouldNotRunFunctionPassesAnalysis
 ; CHECK-O-NEXT: Running analysis: ShouldNotRunFunctionPassesAnalysis
-; CHECK-DEFAULT-NEXT: Running pass: CoroSplitPass
-; CHECK-LTO-NOT: Running pass: CoroSplitPass
+; CHECK-O-NEXT: Running pass: CoroSplitPass
 ; CHECK-O-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}ShouldNotRunFunctionPassesAnalysis
 ; CHECK-O-NEXT: Invalidating analysis: ShouldNotRunFunctionPassesAnalysis
 ; CHECK-O-NEXT: Invalidating analysis: InlineAdvisorAnalysis
 ; CHECK-O-NEXT: Running pass: DeadArgumentEliminationPass
-; CHECK-DEFAULT-NEXT: Running pass: CoroCleanupPass
-; CHECK-LTO-NOT: Running pass: CoroCleanupPass
+; CHECK-O-NEXT: Running pass: CoroCleanupPass
 ; CHECK-O-NEXT: Running pass: GlobalOptPass
 ; CHECK-O-NEXT: Running pass: GlobalDCEPass
 ; CHECK-DEFAULT-NEXT: Running pass: EliminateAvailableExternallyPass

@apolloww apolloww requested a review from sbc100 April 30, 2024 23:54
Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with this code, but it looks reasonable on the surface.

@apolloww apolloww force-pushed the fix_coro_mono_lto branch from a47f820 to cc54ec5 Compare May 1, 2024 01:22
@apolloww apolloww merged commit bafc5f4 into llvm:main May 1, 2024
@apolloww apolloww deleted the fix_coro_mono_lto branch May 1, 2024 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category coroutines C++20 coroutines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants