[PATCH] D32067: [XRay][compiler-rt] Use emulated TSC when CPU supports rdtscp, but cannot determine the CPU frequency
Douglas Yung via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 13 18:15:36 PDT 2017
dyung created this revision.
A problem arises if a machine supports the rdtscp instruction, but the processor frequency cannot be determined by the function getTSCFrequency(). In this case, we want to use the emulated TSC instead. This patch implements that by adding a call to getTSCFrequency() from probeRequiredCPUFeatures(), and the function only returns true if both the processor supports rdtscp and the CPU frequency can be determined.
This should fix PR32620.
https://reviews.llvm.org/D32067
Files:
lib/xray/xray_x86_64.cc
Index: lib/xray/xray_x86_64.cc
===================================================================
--- lib/xray/xray_x86_64.cc
+++ lib/xray/xray_x86_64.cc
@@ -214,6 +214,12 @@
Report("Missing rdtscp support.\n");
return false;
}
+ // Also check whether we can determine the CPU frequency, since if we cannot,
+ // we should use the emulated TSC instead.
+ if (!getTSCFrequency()) {
+ Report("Unable to determine CPU frequency.\n");
+ return false;
+ }
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32067.95250.patch
Type: text/x-patch
Size: 496 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170414/8fc7cf03/attachment.bin>
More information about the llvm-commits
mailing list