[llvm] [BOLT][RISCV] Avoid evaluating indirect branches as direct branches (PR #218088)

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 21 20:11:00 PDT 2026


================
@@ -1423,7 +1423,8 @@ Error BinaryFunction::disassemble() {
 
     if (MIB->isBranch(Instruction) || MIB->isCall(Instruction)) {
       uint64_t TargetAddress = 0;
-      if (MIB->evaluateBranch(Instruction, AbsoluteInstrAddr, Size,
+      if (!MIB->isIndirectBranch(Instruction) &&
+          MIB->evaluateBranch(Instruction, AbsoluteInstrAddr, Size,
----------------
WangJee wrote:

Yes, the check is on the generic path intentionally. But I think this does not change the current X86 or AArch64 behavior: their evaluateBranch() implementations already return false for indirect branches. X86 only evaluates an operand marked OPERAND_PCREL, and AArch64 only evaluates instructions with a PC-relative operand. RISC-V is different because its stateful evaluator can resolve a JALR when the base-register value is known.

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


More information about the llvm-commits mailing list