[PATCH] D31909: [XRay][compiler-rt] Add support for TSC emulation for x86_64 to xray_fdr_logging.cc
Douglas Yung via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 10 15:07:16 PDT 2017
dyung created this revision.
Previously in r297800, a work-around was created to use TSC emulation on x86_64 when RDTSCP was not available on the host. A similar change was needed in the file xray_fdr_logging.cc which this patch ports over to that file.
Eventually the code should be refactored as there will be 3 locations with the same code, but that can be done as a separate step. This patch is just to keep the test from failing on my machine due to an illegal instruction since RDTSCP is not available on my x86_64 linux VM.
https://reviews.llvm.org/D31909
Files:
lib/xray/xray_fdr_logging.cc
Index: lib/xray/xray_fdr_logging.cc
===================================================================
--- lib/xray/xray_fdr_logging.cc
+++ lib/xray/xray_fdr_logging.cc
@@ -192,7 +192,20 @@
// we've seen this CPU before. We also do it before we load anything else, to
// allow for forward progress with the scheduling.
unsigned char CPU;
- uint64_t TSC = __xray::readTSC(CPU);
+ uint64_t TSC;
+
+ if(probeRequiredCPUFeatures()) {
+ TSC = __xray::readTSC(CPU);
+ } else {
+ timespec TS;
+ int result = clock_gettime(CLOCK_REALTIME, &TS);
+ if (result != 0) {
+ Report("clock_gettime(2) return %d, errno=%d", result, int(errno));
+ TS = {0, 0};
+ }
+ CPU = 0;
+ TSC = TS.tv_sec * __xray::NanosecondsPerSecond + TS.tv_nsec;
+ }
__xray_fdr_internal::processFunctionHook(FuncId, Entry, TSC, CPU,
clock_gettime, LoggingStatus, BQ);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31909.94748.patch
Type: text/x-patch
Size: 921 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170410/45672670/attachment.bin>
More information about the llvm-commits
mailing list