diff options
author | Chuanqi Xu <yedeng.yd@linux.alibaba.com> | 2023-08-28 11:39:41 +0800 |
---|---|---|
committer | Chuanqi Xu <yedeng.yd@linux.alibaba.com> | 2023-08-28 11:43:33 +0800 |
commit | 9d9c25f81456aace2bec4b58498a420e650007d9 (patch) | |
tree | 933ab785d192320289ff3fb0d46fa7f7b4611997 /clang/lib/CodeGen/CGCall.cpp | |
parent | 57aee4ea69c73c5be8023d1ba829532a2cdfaa0e (diff) | |
download | llvm-9d9c25f81456aace2bec4b58498a420e650007d9.zip llvm-9d9c25f81456aace2bec4b58498a420e650007d9.tar.gz llvm-9d9c25f81456aace2bec4b58498a420e650007d9.tar.bz2 |
[C++20] [Coroutines] Don't mark await_suspend as noinline if it is specified as always_inline already
Address https://github.com/llvm/llvm-project/issues/64933 and partially
https://github.com/llvm/llvm-project/issues/64945.
After c467245, we will add a noinline attribute to the await_suspend
member function of an awaiter if the awaiter has any non static member
functions.
Obviously, this decision will bring some performance regressions. And
people may complain about this while the long term solution may not be
available soon. In such cases, it is better to provide a solution for
the users who met the regression surprisingly.
Also it is natural to not prevent the inlining if the function is marked
as always_inline by the users already.
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 68d77f7..8acb03c 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -5548,7 +5548,11 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, // Then it is much easier to perform the safety analysis in the middle end. // If it is safe to inline the call to awaitSuspend, we can replace it in the // CoroEarly pass. Otherwise we could replace it in the CoroSplit pass. - if (inSuspendBlock() && mayCoroHandleEscape()) + // + // If the `await_suspend()` function is marked as `always_inline` explicitly, + // we should give the user the right to control the codegen. + if (inSuspendBlock() && mayCoroHandleEscape() && + !TargetDecl->hasAttr<AlwaysInlineAttr>()) Attrs = Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::NoInline); // Disable inlining inside SEH __try blocks. |