This is an archive of the discontinued LLVM Phabricator instance.

[XRay][compiler-rt] Use emulated TSC when CPU supports rdtscp, but cannot determine the CPU frequency
ClosedPublic

Authored by dyung on Apr 13 2017, 6:15 PM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

dyung created this revision.Apr 13 2017, 6:15 PM
dberris edited edge metadata.Apr 17 2017, 4:29 PM

Probably want to make sure that the call-site for probeRequiredCPUFeatures() don't happen in the hot path (i.e. that this check is only done once).

The previous patch that attempted to fix this in FDR mode was calling probeRequiredCPUFeatures() in an if conditional. We should revert that and should do this check once and store the results to a function-local static bool.

dyung updated this revision to Diff 95512.Apr 17 2017, 5:20 PM

I've added a new revision that makes the changes suggested by Dean. I think this should cover all of the cases where probeRequiredCPUFeatures() is calledexcept for the lambda at the end of xray_inmemory_log.cc which I think should only be executed once.

dberris accepted this revision.Apr 17 2017, 8:18 PM

LGTM

This revision is now accepted and ready to land.Apr 17 2017, 8:18 PM
This revision was automatically updated to reflect the committed changes.