-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[builtins] Refactor cpu_model support to reduce #if nesting. NFCI #75635
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
[builtins] Refactor cpu_model support to reduce #if nesting. NFCI #75635
Conversation
Created using spr 1.3.4
✅ With the latest revision this PR passed the C/C++ code formatter. |
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/android.inc
Outdated
Show resolved
Hide resolved
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/fucsia.inc
Outdated
Show resolved
Hide resolved
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc
Outdated
Show resolved
Hide resolved
Created using spr 1.3.4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks reasonable overall, but there's a typo in the name of Fuchsia, which I believe would lead to its codepaths being entirely missed :-)
Thanks, in this form I think the ifdef jungle is much more manageable.
#if defined(__FreeBSD__) | ||
#include "aarch64/fmv/freebsd.inc" | ||
#include "aarch64/fmv/mrs.inc" | ||
#elif defined(__Fucsia__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you've misspelled Fuchsia consistently :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️ thanks
Created using spr 1.3.4
Created using spr 1.3.4
Created using spr 1.3.4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for refactoring! It indeed becomes necessary and looks well-structured now, small nit - rename lse_atomics/fucsia.inc and fmv/fucsia.inc files as well.
Created using spr 1.3.4
Created using spr 1.3.4
Reviewers: petrhosek, DavidSpickett Pull Request: #75635
There were a few follow-ups to address that. Sorry. |
|
@petrhosek I don't have a Fucshia sysroot to build this against, so I think it would help me a lot if you could grab the preprocessed version of the
In that case, if I'm reading it correctly, all of the |
This is a follow up to llvm#75635 which broke the build on Fuchsia. We don't support ifunc on Fuchsia so we shouldn't define __init_cpu_features. For __init_cpu_features_resolver we have to use _zx_system_get_features as a Zircon native solution.
This is a follow up to #75635 which broke the build on Fuchsia. We don't support ifunc on Fuchsia so we shouldn't define __init_cpu_features. For __init_cpu_features_resolver we have to use _zx_system_get_features as a Zircon native solution.
This is a follow-up to #75635 which broke the build for FreeBSD on AArch64: ``` compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc:3:16: error: call to undeclared function 'elf_aux_info'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 3 | int result = elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap); | ^ ``` Using `elf_aux_info()` requires including `<sys/auxv.h>` first. To prevent redeclaration issues with `hwcap.inc` attempting to define `HWCAP_xxx` macros before `<sys/auxv.h>` does so, include `<sys/auxv.h>` before any of the `.inc` files on FreeBSD.
[builtins] Fix CPU feature detection for FreeBSD on AArch64 This is a follow-up to #75635 which broke the build for FreeBSD on AArch64: ``` compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc:3:16: error: call to undeclared function 'elf_aux_info'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 3 | int result = elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap); | ^ ``` Using `elf_aux_info()` requires including `<sys/auxv.h>` first. To prevent redeclaration issues with `hwcap.inc` attempting to define `HWCAP_xxx` macros before `<sys/auxv.h>` does so, include `<sys/auxv.h>` before any of the `.inc` files on FreeBSD.
Reviewers: petrhosek, DavidSpickett Pull Request: llvm#75635
Reviewers: petrhosek, DavidSpickett Pull Request: llvm#75635
The patch complements llvm#68919 and adds AArch64 support for builtin __builtin_cpu_supports("feature1+...+featureN") which return true if all specified CPU features in argument are detected. Also compiler-rt aarch64 native run tests for features detection mechanism were added and 'cpu_model' check was fixed after its refactor merged llvm#75635 Original RFC was https://reviews.llvm.org/D153153
The patch complements llvm#68919 and adds AArch64 support for builtin __builtin_cpu_supports("feature1+...+featureN") which return true if all specified CPU features in argument are detected. Also compiler-rt aarch64 native run tests for features detection mechanism were added and 'cpu_model' check was fixed after its refactor merged llvm#75635 Original RFC was https://reviews.llvm.org/D153153
The patch complements #68919 and adds AArch64 support for builtin `__builtin_cpu_supports("feature1+...+featureN")` which return true if all specified CPU features in argument are detected. Also compiler-rt aarch64 native run tests for features detection mechanism were added and 'cpu_model' check was fixed after its refactor merged #75635 Original RFC was https://reviews.llvm.org/D153153
Reviewers: petrhosek, DavidSpickett Pull Request: llvm/llvm-project#75635
Reviewers: petrhosek, DavidSpickett Pull Request: llvm/llvm-project#75635
llvm/llvm-project#75635 (comment) ``` /b/s/w/ir/x/w/llvm_build/./bin/clang --target=aarch64-unknown-linux-gnu --sysroot=/b/s/w/ir/x/w/cipd/linux -DHAS_ASM_LSE -DVISIBILITY_HIDDEN --target=aarch64-unknown-linux-gnu -O2 -g -DNDEBUG -fno-lto -std=c11 -fPIC -fno-builtin -fvisibility=hidden -fomit-frame-pointer -DCOMPILER_RT_HAS_FLOAT16 -MD -MT CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model/aarch64.c.o -MF CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model/aarch64.c.o.d -o CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model/aarch64.c.o -c /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64.c In file included from /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64.c:43: /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc:5:41: error: use of undeclared identifier 'HWCAP_ATOMICS' 5 | __aarch64_have_lse_atomics = (hwcap & HWCAP_ATOMICS) != 0; | ^ 1 error generated. ```
No description provided.