[all-commits] [llvm/llvm-project] 31e60b: [coroutine] should disable inline before calling c...

Xun Li via All-commits all-commits at lists.llvm.org
Tue Dec 8 08:55:08 PST 2020


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 31e60b9133596c185e6daac7f1761dc17e464826
      https://github.com/llvm/llvm-project/commit/31e60b9133596c185e6daac7f1761dc17e464826
  Author: Xun Li <xun at fb.com>
  Date:   2020-12-08 (Tue, 08 Dec 2020)

  Changed paths:
    M llvm/include/llvm/IR/Function.h
    M llvm/lib/Analysis/InlineCost.cpp
    M llvm/lib/Transforms/IPO/AlwaysInliner.cpp
    A llvm/test/Transforms/Coroutines/Inputs/sample.text.prof
    A llvm/test/Transforms/Coroutines/coro-inline.ll

  Log Message:
  -----------
  [coroutine] should disable inline before calling coro split

This is a rework of D85812, which didn't land.
When callee coroutine function is inlined into caller coroutine function before coro-split pass, llvm will emits "coroutine should have exactly one defining @llvm.coro.begin". It seems that coro-early pass can not handle this quiet well.
So we believe that unsplited coroutine function should not be inlined.
This patch fix such issue by not inlining function if it has attribute "coroutine.presplit" (it means the function has not been splited) to fix this issue
test plan: check-llvm, check-clang

In D85812, there was suggestions on moving the macros to Attributes.td to avoid circular header dependency issue.
I believe it's not worth doing just to be able to use one constant string in one place.
Today, there are already 3 possible attribute values for "coroutine.presplit": https://github.com/llvm/llvm-project/blob/c6543cc6b8f107b58e7205d8fc64865a508bacba/llvm/lib/Transforms/Coroutines/CoroInternal.h#L40-L42
If we move them into Attributes.td, we would be adding 3 new attributes to EnumAttr, just to support this, which I think is an overkill.

Instead, I think the best way to do this is to add an API in Function class that checks whether this function is a coroutine, by checking the attribute by name directly.

Differential Revision: https://reviews.llvm.org/D92706




More information about the All-commits mailing list