Skip to content

[clang] Add intrin0.h header to mimic intrin0.h used by MSVC STL for clang-cl #75711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,26 @@ Windows Support
linking may succeed but the resulting executables may expose issues at
runtime.

- Clang-cl now supports function targets with intrinsic headers. This allows
for runtime feature detection of intrinsics. Previously under clang-cl
``immintrin.h`` and similar intrinsic headers would only include the intrinsics
if building with that feature enabled at compile time, e.g. ``avxintrin.h``
would only be included if AVX was enabled at compile time. This was done to work
around include times from MSVC STL including ``intrin.h`` under clang-cl.
Clang-cl now provides ``intrin0.h`` for MSVC STL and therefore all intrinsic
features without requiring enablement at compile time.
Fixes: (`#53520 <https://github.com/llvm/llvm-project/issues/53520>`_)

- Improved compile times with MSVC STL. MSVC provides ``intrin0.h`` which is a
header that only includes intrinsics that are used by MSVC STL to avoid the
use of ``intrin.h``. MSVC STL when compiled under clang uses ``intrin.h``
instead. Clang-cl now provides ``intrin0.h`` for the same compiler throughput
purposes as MSVC. Clang-cl also provides ``yvals_core.h`` to redefine
``_STL_INTRIN_HEADER`` to expand to ``intrin0.h`` instead of ``intrin.h``.
This also means that if all intrinsic features are enabled at compile time
including STL headers will no longer slow down compile times since ``intrin.h``
is not included from MSVC STL.

LoongArch Support
^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Headers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,10 @@ set(x86_files
)

set(windows_only_files
intrin0.h
intrin.h
vadefs.h
yvals_core.h
)

set(utility_files
Expand Down
6 changes: 2 additions & 4 deletions clang/lib/Headers/bmiintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ _mm_tzcnt_64(unsigned long long __X)

#undef __RELAXED_FN_ATTRS

#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
defined(__BMI__)
#if !defined(__SCE__) || __has_feature(modules) || defined(__BMI__)

/* Define the default attributes for the functions in this file. */
#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("bmi")))
Expand Down Expand Up @@ -425,7 +424,6 @@ __blsr_u64(unsigned long long __X)

#undef __DEFAULT_FN_ATTRS

#endif /* !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) \
|| defined(__BMI__) */
#endif /* !defined(__SCE__) || __has_feature(modules) || defined(__BMI__) */

#endif /* __BMIINTRIN_H */
Loading