[llvm-exegesis] Guard `__builtin_thread_pointer` behind a configure check
authorMarkus Böck <markus.boeck02@gmail.com>
Fri, 21 Jul 2023 05:43:43 +0000 (07:43 +0200)
committerMarkus Böck <markus.boeck02@gmail.com>
Fri, 21 Jul 2023 06:03:26 +0000 (08:03 +0200)
commit822c31a0fe827a6f33601ad6b44eb2818350da36
tree14d2c3fc470c3086f4b4d4502886d61860206ab0
parentf117bbca041c9b0c59002835d939e1bc9e76cf39
[llvm-exegesis] Guard `__builtin_thread_pointer` behind a configure check

Due to arguably a bug in GCC[0], using `__has_builtin` is not sufficient to check whether `__builtin_thread_pointer` can actually be compiled by GCC. This makes it impossible to compile LLVM with `llvm-exegesis` enabled with e.g. GCC 10 as it does have the builtin, but no implementation for architectures such as x86.

This patch works around this issue by making it a cmake configure check whether the builtin can be compiled and used, rather than relying on the broken preprocessor macro.

[0] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96952, demonstration: https://godbolt.org/z/9z5nWM6Ef

Differential Revision: https://reviews.llvm.org/D155828
llvm/cmake/config-ix.cmake
llvm/include/llvm/Config/config.h.cmake
llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp