[compiler-rt] r300017 - [XRay][compiler-rt] Add another work-around to XRay FDR tests when TSC emulation is needed

Douglas Yung via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 18:24:48 PDT 2017


Author: dyung
Date: Tue Apr 11 20:24:48 2017
New Revision: 300017

URL: http://llvm.org/viewvc/llvm-project?rev=300017&view=rev
Log:
[XRay][compiler-rt] Add another work-around to XRay FDR tests when TSC emulation is needed

This patch applies a work-around to the XRay FDR tests when TSC emulation is 
needed because the processor frequency cannot be determined.

This fixes PR32620 using the suggestion given by Dean in comment 1.

Reviewers: dberris

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31967

Modified:
    compiler-rt/trunk/lib/xray/xray_fdr_logging.cc
    compiler-rt/trunk/lib/xray/xray_fdr_logging_impl.h

Modified: compiler-rt/trunk/lib/xray/xray_fdr_logging.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_fdr_logging.cc?rev=300017&r1=300016&r2=300017&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_fdr_logging.cc (original)
+++ compiler-rt/trunk/lib/xray/xray_fdr_logging.cc Tue Apr 11 20:24:48 2017
@@ -120,7 +120,8 @@ XRayLogFlushStatus fdrLoggingFlush() XRA
   XRayFileHeader Header;
   Header.Version = 1;
   Header.Type = FileTypes::FDR_LOG;
-  Header.CycleFrequency = getTSCFrequency();
+  Header.CycleFrequency = probeRequiredCPUFeatures()
+                          ? getTSCFrequency() : __xray::NanosecondsPerSecond;
   // FIXME: Actually check whether we have 'constant_tsc' and 'nonstop_tsc'
   // before setting the values in the header.
   Header.ConstantTSC = 1;

Modified: compiler-rt/trunk/lib/xray/xray_fdr_logging_impl.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_fdr_logging_impl.h?rev=300017&r1=300016&r2=300017&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_fdr_logging_impl.h (original)
+++ compiler-rt/trunk/lib/xray/xray_fdr_logging_impl.h Tue Apr 11 20:24:48 2017
@@ -423,7 +423,9 @@ static inline void processFunctionHook(
       return;
     }
 
-    uint64_t CycleFrequency = getTSCFrequency();
+    uint64_t CycleFrequency = probeRequiredCPUFeatures()
+                              ? getTSCFrequency()
+                              : __xray::NanosecondsPerSecond;
     NumberOfTicksThreshold = CycleFrequency *
                              flags()->xray_fdr_log_func_duration_threshold_us /
                              1000000;




More information about the llvm-commits mailing list