diff --git a/compiler-rt/lib/xray/xray_tsc.h b/compiler-rt/lib/xray/xray_tsc.h index 17e06c7035d85..118b6f00e33ea 100644 --- a/compiler-rt/lib/xray/xray_tsc.h +++ b/compiler-rt/lib/xray/xray_tsc.h @@ -96,7 +96,13 @@ namespace __xray { inline bool probeRequiredCPUFeatures() XRAY_NEVER_INSTRUMENT { return true; } ALWAYS_INLINE uint64_t readTSC(uint8_t &CPU) XRAY_NEVER_INSTRUMENT { +#if __has_builtin(__builtin_readcyclecounter) return __builtin_readcyclecounter(); +#else + uint64_t Cycles; + asm volatile("stckf %0" : : "Q"(Cycles) : "cc"); + return Cycles; +#endif } inline uint64_t getTSCFrequency() XRAY_NEVER_INSTRUMENT {