[PATCH] D115790: [Coroutines] Run CoroEarly Pass in front of AlwaysInliner in O0 pass and warn for always_inline coroutine

Chuanqi Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 15 02:52:11 PST 2021


ChuanqiXu created this revision.
ChuanqiXu added reviewers: rjmccall, lxfind, aeubanks.
ChuanqiXu added a project: clang.
Herald added subscribers: ormris, steven_wu, hiraditya.
ChuanqiXu requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits.
Herald added a project: LLVM.

See https://reviews.llvm.org/D100282 and https://github.com/llvm/llvm-project/issues/49264 for the background.
Simply, coroutine shouldn't be inlined before CoroSplit. And the marker for pre-splited coroutine is created in  CoroEarly pass, which ran after AlwaysInliner Pass in O0 pipeline. So that the AlwaysInliner couldn't detect it shouldn't inline a coroutine. So here is the error.

In D100282 <https://reviews.llvm.org/D100282>, we have discussed how should we fix this bug. Should we move the CoroEarly pass in front of AlwaysInliner? Or should we make it in the frontend. According to @lxfind , it would be better to move the CoroEarly pass.

And I have another reason to not implement it in the frontend. Since I found that if we make it in the frontend, we need to edit the `Coroutines.rst` document to tell that the frontend should emit a `"coroutine.presplit"` attribute (at least for switch-resumed ABI), it is weird. Since it is required all the time, it should be done automatically in the middle end. So I think it would be better to move the CoroEarly pass.

BTW, according to the discuss in D100282 <https://reviews.llvm.org/D100282>, it is suggested that we should add a warning for marking a coroutine as `always_inline`. I implement it in this patch. But I am willing to split it if required.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115790

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaCoroutine.cpp
  clang/test/CodeGen/lto-newpm-pipeline.c
  clang/test/CodeGenCoroutines/coro-always-inline.cpp
  clang/test/SemaCXX/coroutines.cpp
  llvm/lib/Passes/PassBuilderPipelines.cpp
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-O0-defaults.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115790.394501.patch
Type: text/x-patch
Size: 7623 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211215/387c2837/attachment.bin>


More information about the cfe-commits mailing list