#81331 added support for a __builtin_readsteadycounter intrinsic which returns a fixed frequency clock counter. It returns 0 on failure.
x86 can use this as a wrapper to read the MPERF counter - on Intel (and default) I think this will need to lower to a libcall, but on AMD znver2 (or later) we can use the RDPRU instruction.
Ideally we need a companion __builtin_readvariablecounter intrinsic which returns the APERF counter to calculate the effective cpu frequency (we can't use __builtin_readcyclecounter as that returns RDTSC which is a different time scale).