[AArch64] Lower READCYCLECOUNTER using MRS CNTVCT_EL0
authorSalvatore Dipietro <dipiets@amazon.com>
Fri, 9 Dec 2022 10:36:16 +0000 (10:36 +0000)
committerDavid Green <david.green@arm.com>
Fri, 9 Dec 2022 10:36:16 +0000 (10:36 +0000)
commit3a894fd90b0569b4ddd9782e3ab3a4b1e85c0075
treed476137a5b6cfb94237e5ba92768a4d49364ccda
parent195af8e034f08de9b620fb434a4e816c74575e86
[AArch64] Lower READCYCLECOUNTER using MRS CNTVCT_EL0

As suggested in D12425 it would be better for the readcyclecounter
function on ARM architecture to use the CNTVCT_EL0 register
(Counter-timer Virtual Count register) instead of the PMCCNTR_EL0
(Performance Monitors Cycle Count Register) because the PMCCNTR_EL0 is a
PMU register which, depending on the configuration, it might always
return zeroes and it doesn't guaranteed to always be increased.

Differential Revision: https://reviews.llvm.org/D136999
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/test/CodeGen/AArch64/mattr-all.ll
llvm/test/CodeGen/AArch64/readcyclecounter.ll