[llvm] Fix the inaccurate profile data check (PR #136278)

via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 18 01:20:15 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-bolt

Author: wangjue (WangJee)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/136278.diff


1 Files Affected:

- (modified) bolt/lib/Profile/DataReader.cpp (+3) 


``````````diff
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);

``````````

</details>


https://github.com/llvm/llvm-project/pull/136278


More information about the llvm-commits mailing list