Skip to content

Commit c9d90f1

Browse files
authored
[Exegesis][AArch64] Use more generic cycles counter (#133376)
CPU_CYCLES counter does not work on some Aarch64 CPUs; CYCLES is more generic and is equivalent to CPU_CYCLES in case the latter is supported. Longer story - CPU_CYCLES work only on CPU models explicitly recognized by libpfm4 ( via pfm_arm_detect_*() functions in https://sourceforge.net/p/perfmon2/libpfm4/ci/master/tree/lib/pfmlib_arm_armv8.c ) and its name is consistent with ARM documentation. However, the counter is architectural and is supported on all ARMv8 CPUs; libpfm4 recognizes generic PMU on unknown ARMv8 CPUs, but does not provide CPU_CYCLES event. Instead, CYCLES is provided (an alias to PERF_COUNT_HW_CPU_CYCLES). Physically, it is the same event with code 0x11. On supported architectures CYCLES also work, so the change should not introduce regression.
1 parent 5b6386d commit c9d90f1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

llvm/lib/Target/AArch64/AArch64PfmCounters.td

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
def CpuCyclesPfmCounter : PfmCounter<"CPU_CYCLES">;
13+
def CpuCyclesPfmCounter : PfmCounter<"CYCLES">;
1414

1515
def DefaultPfmCounters : ProcPfmCounters {
1616
let CycleCounter = CpuCyclesPfmCounter;

llvm/unittests/tools/llvm-exegesis/AArch64/TargetTest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ TEST_F(AArch64TargetTest, SetRegToConstant) {
6565
}
6666

6767
TEST_F(AArch64TargetTest, DefaultPfmCounters) {
68-
const std::string Expected = "CPU_CYCLES";
68+
const std::string Expected = "CYCLES";
6969
EXPECT_EQ(ExegesisTarget_->getPfmCounters("").CycleCounter, Expected);
7070
EXPECT_EQ(ExegesisTarget_->getPfmCounters("unknown_cpu").CycleCounter,
7171
Expected);

0 commit comments

Comments
 (0)