[clang] [clang] Add support for `[[msvc::forceinline]]` (PR #185282)
Trung Nguyen via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 27 05:10:54 PDT 2026
================
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++23 -emit-llvm %s -triple x86_64-pc-windows-msvc -o - | FileCheck %s
+
+[[msvc::forceinline]] void func() {}
+
+void call_func() {
+// CHECK-LABEL: @"?call_func@@YAXXZ"()
+// CHECK-NOT: call void @"?func@@YAXXZ"()
+ func();
+}
+
+void call_lambda() {
+// CHECK-LABEL: @"?call_lambda@@YAXXZ"()
+// CHECK-NOT: call void @"??R<lambda_
----------------
trungnt2910 wrote:
Even then, there are no attributes at the call site:
```
define dso_local void @call_func()() #1 !dbg !14 {
call void @func()(), !dbg !15
ret void, !dbg !16
}
```
On the other hand, if you add a `[[clang::always_inline]]` at the call site (i.e. ` [[clang::always_inline]] func();`), you will get:
```
define dso_local void @call_func()() #1 !dbg !14 {
call void @func()() #4, !dbg !15
ret void, !dbg !16
}
attributes #4 = { alwaysinline }
```
This applies even to the existing `[[clang::always_inline]]`: https://godbolt.org/z/88cjb7ffq
https://github.com/llvm/llvm-project/pull/185282
More information about the cfe-commits
mailing list