[llvm] Fix the inaccurate profile data check (PR #136278)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 18 01:19:37 PDT 2025
https://github.com/WangJee created https://github.com/llvm/llvm-project/pull/136278
The error is caused by the fact that when acquiring the profile data, the instruction at offset is PseudoCALL, but when performing profile verification, PseudoCALL is converted to AUIPC and JALR instructions, and the offset obtained is JALR; therefore, the profile data is considered invalid.
>From a27deb9a40b91f34423879cceb6d70ae272aa338 Mon Sep 17 00:00:00 2001
From: wangjue <wangjue at zhcomputing.com>
Date: Fri, 18 Apr 2025 08:15:07 +0000
Subject: [PATCH] Fix the inaccurate profile data check
---
bolt/lib/Profile/DataReader.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/bolt/lib/Profile/DataReader.cpp b/bolt/lib/Profile/DataReader.cpp
index f2e999bbfdc6d..258a36c86afb2 100644
--- a/bolt/lib/Profile/DataReader.cpp
+++ b/bolt/lib/Profile/DataReader.cpp
@@ -524,6 +524,9 @@ float DataReader::evaluateProfileData(BinaryFunction &BF,
// when we identify tail calls, so they are still represented
// by regular branch instructions and we need isBranch() here.
MCInst *Instr = BF.getInstructionAtOffset(BI.From.Offset);
+ // If t's a RISCV PseudoCALL - fix it
+ if (!Instr && BC.isRISCV())
+ Instr = BF.getInstructionAtOffset(BI.From.Offset + 4);
// If it's a prefix - skip it.
if (Instr && BC.MIB->isPrefix(*Instr))
Instr = BF.getInstructionAtOffset(BI.From.Offset + 1);
More information about the llvm-commits
mailing list