[llvm-branch-commits] [llvm] [LLVM][Coroutines] Transform "coro_must_elide" calls to switch ABI coroutines to the `noalloc` variant (PR #99285)

Adrian Vogelsgesang via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jul 19 16:03:45 PDT 2024


================
@@ -968,8 +969,8 @@ PassBuilder::buildInlinerPipeline(OptimizationLevel Level,
   // it's been modified since.
   MainCGPipeline.addPass(createCGSCCToFunctionPassAdaptor(
       RequireAnalysisPass<ShouldNotRunFunctionPassesAnalysis, Function>()));
-
   MainCGPipeline.addPass(CoroSplitPass(Level != OptimizationLevel::O0));
+  MainCGPipeline.addPass(CoroAnnotationElidePass());
----------------
vogelsgesang wrote:

Should this optimization also work for ThinLTO? (also see discussion in https://github.com/llvm/llvm-project/pull/99283#discussion_r1684973257)

I read this pass setup a bit more carefully now, and I don't think it will work for ThinLTO.

Why?

* Both `CoroAnnotationElide` and `CoroSplit` are added to `buildInlinerPipeline`.
* `buildInlinerPipeline` is used by `buildModuleSimplificationPipeline`.
* `buildModuleSimplificationPipeline` is part of both `buildThinLTOPreLinkDefaultPipeline` and `buildThinLTODefaultPipeline`
* -> `CoroSplit` already runs as part of `buildThinLTOPreLinkDefaultPipeline` (i.e. on a per-translation-unit-level)
* -> by the time we reach `buildThinLTODefaultPipeline` (i.e. the cross-TU part of ThinLTO), the coroutines are already split
* -> although, `CoroAnnotationElide` is run a 2nd time as part of cross-TU optimization, it will be a no-op due to the `Caller->isPresplitCoroutine()` check in `CoroAnnotationElide.cpp:120`

https://github.com/llvm/llvm-project/pull/99285


More information about the llvm-branch-commits mailing list