aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2023-11-01 18:12:16 +0000
committerMichał Górny <mgorny@gentoo.org>2023-11-14 14:09:45 +0100
commit722dfa07bde82794fc7c77f31d694070f36a1679 (patch)
tree156bc8d14f58746b923640ec2f71e9f0c9b71ce7
parent[BranchFolding] Remove dubious assert from operator< (#71639) (diff)
downloadllvm-project-gentoo-17.0.5.tar.gz
llvm-project-gentoo-17.0.5.tar.bz2
llvm-project-gentoo-17.0.5.zip
[CMake] Fix __builtin_thread_pointer check with LTOgentoo-17.0.5
With LTO, gcc's IPA passes might drop the foo() function and then the test will pass even on platforms where __builtin_thread_pointer is unavailable. On PPC64, we get this as a result: ``` llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp:361:61: error: ‘__builtin_thread_pointer’ is not supported on this targ ``` Just mark the function in the CMake configure test with the 'used' attribute to avoid it being optimised out. The test then behaves correctly with -flto. Tested with e.g. 'powerpc64le-linux-gnu-gcc -O2 -flto a.c'. Reported-by: matoro Reviewed-by: maskray Closes: https://github.com/llvm/llvm-project/pull/70968 Signed-off-by: Sam James <sam@gentoo.org> Gentoo-Component: llvm
-rw-r--r--llvm/cmake/config-ix.cmake7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index f63c3f1a351f..880e1adb9c34 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -65,7 +65,12 @@ check_include_file(fenv.h HAVE_FENV_H)
check_symbol_exists(FE_ALL_EXCEPT "fenv.h" HAVE_DECL_FE_ALL_EXCEPT)
check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT)
check_c_source_compiles("
- void *foo() {
+ #if __has_attribute(used)
+ #define LLVM_ATTRIBUTE_USED __attribute__((__used__))
+ #else
+ #define LLVM_ATTRIBUTE_USED
+ #endif
+ LLVM_ATTRIBUTE_USED void *foo() {
return __builtin_thread_pointer();
}
int main(void) { return 0; }"