-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[compiler-rt][X86] Use functions in cpuid.h instead of inline assembly #97877
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
[compiler-rt][X86] Use functions in cpuid.h instead of inline assembly #97877
Conversation
This patch makes the host/feature detection in compiler-rt and LLVM use the functions provided in cpuid.h(__get_cpuid, __get_cpuid_count) instead of inline assembly. This simplifies the implementation and moves any inline assembly away to a more common place. A while ago, some similar cleanup was attempted, but this ended up resulting in some compilation errors due to toolchain minimum version issues (https://bugs.llvm.org/show_bug.cgi?id=30384). After the reversion landed, there have been no attempts since then to clean up the code, even though the minimum supported compilers now support the relevant functions (https://godbolt.org/z/o1Mjz8ndv).
✅ With the latest revision this PR passed the C/C++ code formatter. |
clang/lib/Headers/cpuid.h did not define |
Yep. I was a bit surprised when I saw everything was included in the minimum supported compiler versions as well. It definitely makes the code a lot cleaner and hopefully more robust as now there's one less inline assembly implementation. |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/71/builds/1636 Here is the relevant piece of the build log for the reference:
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/162/builds/1578 Here is the relevant piece of the build log for the reference:
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/129/builds/1509 Here is the relevant piece of the build log for the reference:
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/89/builds/1597 Here is the relevant piece of the build log for the reference:
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/157/builds/1991 Here is the relevant piece of the build log for the reference:
|
… assembly (llvm#97877)" This reverts commit f6616e9. Was causing buildbot failures on Windows. I also remember seeing a AMDGPU buildbot failing somewhere on a warning as they have -Werror enabled.
… assembly (#97877)" This reverts commit f1905f0. This relands commit 19cf8de. There were issues with the preprocessor includes that should have excluded MSVC still including clang functions building on windows and using intrin.h. This relanding fixes this behavior by additionally wrapping the uses of __get_cpuid and __get_cpuid_count in _MSC_VER so that clang in MSVC mode, which includes intrin.h, does not have any conflicts.
… assembly (#97877)" Summary: This reverts commit f1905f0. This relands commit 19cf8de. There were issues with the preprocessor includes that should have excluded MSVC still including clang functions building on windows and using intrin.h. This relanding fixes this behavior by additionally wrapping the uses of __get_cpuid and __get_cpuid_count in _MSC_VER so that clang in MSVC mode, which includes intrin.h, does not have any conflicts. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250754
@boomanaiden154 this is causing a build regression when compiling standalone compiler-rt for x86_64 in a cross build environment
if I manually add |
You're going to have to provide more details about your environment. The compiler invocation should theoretically pickup the builtin headers. I'm not sure why it isn't in your environment. That (to me) seems like an issue with your environment rather than an issue with the patch though. |
its possible, let me do a bit more diving, if I revert this patch then it starts to build which is perhaps that it does not need to include the header so it works. |
yeah pilot error ! a rebase of local patch went wrong. sorry for noise. |
This patch makes the host/feature detection in compiler-rt and LLVM use the functions provided in cpuid.h(__get_cpuid, __get_cpuid_count) instead of inline assembly. This simplifies the implementation and moves any inline assembly away to a more common place.
A while ago, some similar cleanup was attempted, but this ended up resulting in some compilation errors due to toolchain minimum version issues (https://bugs.llvm.org/show_bug.cgi?id=30384). After the reversion landed, there have been no attempts since then to clean up the code, even though the minimum supported compilers now support the relevant functions (https://godbolt.org/z/o1Mjz8ndv).