[compiler-rt] [SystemZ][XRay] Make xray work with gcc (PR #126154)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 6 15:47:18 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-xray

Author: Kai Nacke (redstar)

<details>
<summary>Changes</summary>

It seems that depending on the platform, gcc acceptts or does not accept `-mvx` without specifying an architecture actually having vector instructions. The solution which seems to work across different versions of gcc and clang is to specify the least architecture which has vector instructions.

In addition, initialization of the unused variable CPU prevents a compiler warning from gcc.

---
Full diff: https://github.com/llvm/llvm-project/pull/126154.diff


2 Files Affected:

- (modified) compiler-rt/lib/xray/CMakeLists.txt (+1-1) 
- (modified) compiler-rt/lib/xray/xray_tsc.h (+1) 


``````````diff
diff --git a/compiler-rt/lib/xray/CMakeLists.txt b/compiler-rt/lib/xray/CMakeLists.txt
index 673091807e348d..c79b0b634ddf16 100644
--- a/compiler-rt/lib/xray/CMakeLists.txt
+++ b/compiler-rt/lib/xray/CMakeLists.txt
@@ -111,7 +111,7 @@ set(riscv64_SOURCES
   xray_trampoline_s390x.S
   )
 # Enable vector instructions in the assembly file.
-set_source_files_properties(xray_trampoline_s390x.S PROPERTIES COMPILE_FLAGS -mvx)
+set_source_files_properties(xray_trampoline_s390x.S PROPERTIES COMPILE_FLAGS -march=z13)
 
 set(XRAY_SOURCE_ARCHS
   arm
diff --git a/compiler-rt/lib/xray/xray_tsc.h b/compiler-rt/lib/xray/xray_tsc.h
index 118b6f00e33ea5..c8a8b2f16fef84 100644
--- a/compiler-rt/lib/xray/xray_tsc.h
+++ b/compiler-rt/lib/xray/xray_tsc.h
@@ -96,6 +96,7 @@ namespace __xray {
 inline bool probeRequiredCPUFeatures() XRAY_NEVER_INSTRUMENT { return true; }
 
 ALWAYS_INLINE uint64_t readTSC(uint8_t &CPU) XRAY_NEVER_INSTRUMENT {
+  CPU = 0;
 #if __has_builtin(__builtin_readcyclecounter)
   return __builtin_readcyclecounter();
 #else

``````````

</details>


https://github.com/llvm/llvm-project/pull/126154


More information about the llvm-commits mailing list