This is an archive of the discontinued LLVM Phabricator instance.

[llvm-exegesis] Guard `__builtin_thread_pointer` behind a configure check
ClosedPublic

Authored by zero9178 on Jul 20 2023, 5:48 AM.

Details

Summary

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

Diff Detail

Event Timeline

zero9178 created this revision.Jul 20 2023, 5:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2023, 5:48 AM
zero9178 requested review of this revision.Jul 20 2023, 5:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2023, 5:49 AM
MaskRay accepted this revision.Jul 20 2023, 12:31 PM

This is unfortunate... LG, but I'll defer to llvm-exegesis reviewers for a second opinion.

llvm/cmake/config-ix.cmake
68

LLVM style uses void *

This revision is now accepted and ready to land.Jul 20 2023, 12:31 PM
zero9178 updated this revision to Diff 542641.Jul 20 2023, 12:56 PM
zero9178 marked an inline comment as done.

Fix code style

aidengrossman accepted this revision.Jul 20 2023, 5:49 PM

LGTM. Definitely not ideal, but we want code that works rather than code that is aesthetically pleasing.