Skip to content

Commit 4c5413f

Browse files
committed
[BOLT] Use the isRISCVCall function to determine whether it is auipc+jalr instruction
1 parent 33f6b28 commit 4c5413f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4658,10 +4658,18 @@ MCInst *BinaryFunction::getInstructionAtOffset(uint64_t Offset) {
46584658
if (!BB)
46594659
return nullptr;
46604660

4661+
MCInst preInst;
46614662
for (MCInst &Inst : *BB) {
46624663
constexpr uint32_t InvalidOffset = std::numeric_limits<uint32_t>::max();
46634664
if (Offset == BC.MIB->getOffsetWithDefault(Inst, InvalidOffset))
46644665
return &Inst;
4666+
// If it's a RISCV PseudoCALL - fix it
4667+
if (BC.isRISCV() &&
4668+
Offset == BC.MIB->getOffsetWithDefault(Inst, InvalidOffset) - 4) {
4669+
if (BC.MIB->isRISCVCall(preInst, Inst))
4670+
return &Inst;
4671+
}
4672+
preInst = Inst;
46654673
}
46664674

46674675
if (MCInst *LastInstr = BB->getLastNonPseudoInstr()) {

bolt/lib/Profile/DataReader.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,6 @@ float DataReader::evaluateProfileData(BinaryFunction &BF,
524524
// when we identify tail calls, so they are still represented
525525
// by regular branch instructions and we need isBranch() here.
526526
MCInst *Instr = BF.getInstructionAtOffset(BI.From.Offset);
527-
// If it's a RISCV PseudoCALL - fix it
528-
if (!Instr && BC.isRISCV())
529-
Instr = BF.getInstructionAtOffset(BI.From.Offset + 4);
530527
// If it's a prefix - skip it.
531528
if (Instr && BC.MIB->isPrefix(*Instr))
532529
Instr = BF.getInstructionAtOffset(BI.From.Offset + 1);

0 commit comments

Comments
 (0)