[clang] [CodeGen] Set attributes on coroutine wrapper functions (PR #207961)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 7 03:26:50 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-codegen
Author: Nikita Popov (nikic)
<details>
<summary>Changes</summary>
Call SetInternalFunctionAttributes() so that target feature attributes get set. This ensures that inlining works without having to reason about target-specific inline compatibility logic.
---
Full diff: https://github.com/llvm/llvm-project/pull/207961.diff
4 Files Affected:
- (modified) clang/lib/CodeGen/CGCoroutine.cpp (+2)
- (modified) clang/test/CodeGenCoroutines/coro-elide.cpp (-3)
- (modified) clang/test/CodeGenCoroutines/coro-halo.cpp (-3)
- (modified) clang/test/CodeGenCoroutines/pr65018.cpp (-3)
``````````diff
diff --git a/clang/lib/CodeGen/CGCoroutine.cpp b/clang/lib/CodeGen/CGCoroutine.cpp
index c1ea145934143..bf896f1338ab4 100644
--- a/clang/lib/CodeGen/CGCoroutine.cpp
+++ b/clang/lib/CodeGen/CGCoroutine.cpp
@@ -437,6 +437,7 @@ CodeGenFunction::generateAwaitSuspendWrapper(Twine const &CoroName,
llvm::Function *Fn = llvm::Function::Create(
LTy, llvm::GlobalValue::InternalLinkage, FuncName, &CGM.getModule());
+ CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI);
Fn->addParamAttr(0, llvm::Attribute::AttrKind::NonNull);
Fn->addParamAttr(0, llvm::Attribute::AttrKind::NoUndef);
@@ -444,6 +445,7 @@ CodeGenFunction::generateAwaitSuspendWrapper(Twine const &CoroName,
Fn->addParamAttr(1, llvm::Attribute::AttrKind::NoUndef);
Fn->setMustProgress();
+ Fn->removeFnAttr(llvm::Attribute::AttrKind::NoInline);
Fn->addFnAttr(llvm::Attribute::AttrKind::AlwaysInline);
Fn->addFnAttr("sample-profile-suffix-elision-policy", "selected");
diff --git a/clang/test/CodeGenCoroutines/coro-elide.cpp b/clang/test/CodeGenCoroutines/coro-elide.cpp
index 3bff2a29c6e07..1902dd64b5e5a 100644
--- a/clang/test/CodeGenCoroutines/coro-elide.cpp
+++ b/clang/test/CodeGenCoroutines/coro-elide.cpp
@@ -1,8 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -O2 -emit-llvm %s -o - | FileCheck %s
-// FIXME: Generate wrappers with correct target features.
-// REQUIRES: x86-registered-target
-
#include "Inputs/coroutine.h"
namespace {
diff --git a/clang/test/CodeGenCoroutines/coro-halo.cpp b/clang/test/CodeGenCoroutines/coro-halo.cpp
index 6dd785f5c1f8e..e75bedaf81fa2 100644
--- a/clang/test/CodeGenCoroutines/coro-halo.cpp
+++ b/clang/test/CodeGenCoroutines/coro-halo.cpp
@@ -3,9 +3,6 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -O2 -emit-llvm %s \
// RUN: -fcxx-exceptions -fexceptions -o - | FileCheck %s
-// FIXME: Generate wrappers with correct target features.
-// REQUIRES: x86-registered-target
-
#include "Inputs/coroutine.h"
#include "Inputs/numeric.h"
diff --git a/clang/test/CodeGenCoroutines/pr65018.cpp b/clang/test/CodeGenCoroutines/pr65018.cpp
index f3b903dc0b396..f1cde461cabc2 100644
--- a/clang/test/CodeGenCoroutines/pr65018.cpp
+++ b/clang/test/CodeGenCoroutines/pr65018.cpp
@@ -1,9 +1,6 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
// RUN: -O1 -emit-llvm %s -o - | FileCheck %s
-// FIXME: Generate wrappers with correct target features.
-// REQUIRES: x86-registered-target
-
#include "Inputs/coroutine.h"
// A simple awaiter type with an await_suspend method that can't be
``````````
</details>
https://github.com/llvm/llvm-project/pull/207961
More information about the cfe-commits
mailing list