[llvm] 8f90a5c - [llvm-exegesis] Guard __builtin_thread_pointer use with __has_builtin

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 17 16:42:16 PDT 2023


Author: Fangrui Song
Date: 2023-07-17T16:42:11-07:00
New Revision: 8f90a5cc45db3267dbc512d512dcb9e4e9193c9c

URL: https://github.com/llvm/llvm-project/commit/8f90a5cc45db3267dbc512d512dcb9e4e9193c9c
DIFF: https://github.com/llvm/llvm-project/commit/8f90a5cc45db3267dbc512d512dcb9e4e9193c9c.diff

LOG: [llvm-exegesis] Guard __builtin_thread_pointer use with __has_builtin

While Clang targets have supported __builtin_thread_pointer for a very
long time (e.g., 2007 for AArch32, 2015 for AArch64), for some GCC
ports, the support is very new (11.0 for x86[1], while we need to
support GCC 7), and many ports haven't implemented
__builtin_thread_pointer yet (m68k, powerpc, etc).

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96955

Added: 
    

Modified: 
    llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index 8197cbdbafbada..370eb886069ca1 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -38,7 +38,7 @@
 #include <sys/wait.h>
 #include <unistd.h>
 
-#if defined(__GLIBC__) && __has_include(<sys/rseq.h>)
+#if defined(__GLIBC__) && __has_include(<sys/rseq.h>) && __has_builtin(__builtin_thread_pointer)
 #include <sys/rseq.h>
 #ifdef RSEQ_SIG
 #define GLIBC_INITS_RSEQ


        


More information about the llvm-commits mailing list