Skip to content

Commit 0b6e040

Browse files
authored
[RISCV] Exclude X1 and X5 from register scavenging for long branch. (#80215)
When a branch target is too far away we need to emit an indirect branch. We scavenge a register for this since we don't know we need this until after register allocation. Jumps using X1 and X5 as the source are hints to the hardware to pop the return-address stack. We should avoiding using them for jumps that aren't a return or tail call.
1 parent 44d85c5 commit 0b6e040

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ void RISCVInstrInfo::insertIndirectBranch(MachineBasicBlock &MBB,
11151115
// FIXME: A virtual register must be used initially, as the register
11161116
// scavenger won't work with empty blocks (SIInstrInfo::insertIndirectBranch
11171117
// uses the same workaround).
1118-
Register ScratchReg = MRI.createVirtualRegister(&RISCV::GPRRegClass);
1118+
Register ScratchReg = MRI.createVirtualRegister(&RISCV::GPRJALRRegClass);
11191119
auto II = MBB.end();
11201120
// We may also update the jump target to RestoreBB later.
11211121
MachineInstr &MI = *BuildMI(MBB, II, DL, get(RISCV::PseudoJump))

0 commit comments

Comments
 (0)