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

Douglas Yung via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 17:49:05 PDT 2017


dyung created this revision.

This patch implements the work-around suggested by Dean in PR32620 comment 1 to fix the problem in that bug. The only difference is that the change was required in two places, not just one.

With this patch, the test "XRay-x86_64-linux :: TestCases/Linux/fdr-mode.cc" should now pass on a x86_64 linux machine that does not have support for rdtscp.


https://reviews.llvm.org/D31967

Files:
  lib/xray/xray_fdr_logging.cc
  lib/xray/xray_fdr_logging_impl.h


Index: lib/xray/xray_fdr_logging_impl.h
===================================================================
--- lib/xray/xray_fdr_logging_impl.h
+++ lib/xray/xray_fdr_logging_impl.h
@@ -423,7 +423,9 @@
       return;
     }
 
-    uint64_t CycleFrequency = getTSCFrequency();
+    uint64_t CycleFrequency = probeRequiredCPUFeatures()
+                              ? getTSCFrequency()
+                              : __xray::NanosecondsPerSecond;
     NumberOfTicksThreshold = CycleFrequency *
                              flags()->xray_fdr_log_func_duration_threshold_us /
                              1000000;
Index: lib/xray/xray_fdr_logging.cc
===================================================================
--- lib/xray/xray_fdr_logging.cc
+++ lib/xray/xray_fdr_logging.cc
@@ -120,7 +120,8 @@
   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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31967.94915.patch
Type: text/x-patch
Size: 1221 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170412/f65f403b/attachment.bin>


More information about the llvm-commits mailing list