[clang] [Clang] [docs] [MSVC] Add sections on `__forceinline` and intrinsic behaviour differences between Clang and MSVC (PR #99426)

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 18 14:47:48 PDT 2024


================
@@ -154,3 +154,133 @@ a hint suggesting how to fix the problem.
 As of this writing, Clang is able to compile a simple ATL hello world
 application.  There are still issues parsing WRL headers for modern Windows 8
 apps, but they should be addressed soon.
+
+__forceinline behavior
+======================
+
+``__forceinline`` behaves like ``[[clang::always_inline]]``.
+Inlining is always attempted regardless of optimization level.
+
+This differs from MSVC where ``__forceinline`` is only respected once inline expansion is enabled
+which allows any function marked implicitly or explicitly ``inline`` or ``__forceinline`` to be expanded.
+Therefore functions marked ``__forceinline`` will be expanded when the optimization level is ``/Od`` unlike
+MSVC where ``__forceinline`` will not be expanded under ``/Od``.
+
+SIMD and instruction set intrinsic behavior
----------------
rnk wrote:

Thanks for writing this up. This is a major point of incompatibility for users, and it's not something we can easily address in Clang or LLVM. LLVM tracks subtarget features on the function, and in Clang, vector intrinsics are "raised" into vector math, losing track of the specific instructions the user wants to select.

https://github.com/llvm/llvm-project/pull/99426


More information about the cfe-commits mailing list