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

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 30 00:35:34 PDT 2026


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/189331.diff


1 Files Affected:

- (modified) bolt/lib/Core/BinaryFunction.cpp (+8) 


``````````diff
diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index c5aefe685de34..0de2d80161cd6 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -4745,10 +4745,18 @@ MCInst *BinaryFunction::getInstructionAtOffset(uint64_t Offset) {
     if (!BB)
       return nullptr;
 
+    MCInst preInst = nullptr;
     for (MCInst &Inst : *BB) {
       constexpr uint32_t InvalidOffset = std::numeric_limits<uint32_t>::max();
       if (Offset == BC.MIB->getOffsetWithDefault(Inst, InvalidOffset))
         return &Inst;
+      // If it's a RISCV PseudoCALL - fix it
+      if (preInst &&
+          Offset == BC.MIB->getOffsetWithDefault(Inst, InvalidOffset) - 4) {
+        if (BC.MIB->isRISCVCall(preInst, Inst))
+          return &Inst;
+      }
+      preInst = Inst;
     }
 
     if (MCInst *LastInstr = BB->getLastNonPseudoInstr()) {

``````````

</details>


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


More information about the llvm-commits mailing list