[PATCH] D30677: [XRay][compiler-rt] Support TSC emulation even for x86_64

Martin Pelikán via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 6 22:20:02 PST 2017


pelikan added inline comments.


================
Comment at: lib/xray/xray_inmemory_log.cc:141-150
+  __xray_InMemoryRawLog(FuncId, Type, [](uint8_t &CPU) XRAY_NEVER_INSTRUMENT {
+    timespec TS;
+    int result = clock_gettime(CLOCK_REALTIME, &TS);
+    if (result != 0) {
+      Report("clock_gettimg(2) return %d, errno=%d.", result, int(errno));
+      TS = {0, 0};
+    }
----------------
This lambda is already in xray_tsc.h as ALWAYS_INLINE.  I remember the discussion about how important it is to have it inlined, and here it's a copy+paste lambda with unclear inliner results.  Why can't we just use the readTSC function pointer here?

In that case we'll have to rename it to something like emulateTSC and move out of the #elif, as (in this case) readTSC is a real thing reading the real TSC.  And then even the other architectures' code would look clearer, because they *emulate* TSC, not *read* it.  Intel and Power would call "read" and others would call "emulate".


https://reviews.llvm.org/D30677





More information about the llvm-commits mailing list