Skip to content

Commit ac40958

Browse files
committed
Include Interrupt Callee-Saves in Min/MaxCSRFrameIndex
1 parent c27f1b0 commit ac40958

File tree

2 files changed

+260
-249
lines changed

2 files changed

+260
-249
lines changed

llvm/lib/Target/RISCV/RISCVFrameLowering.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2021,11 +2021,22 @@ bool RISCVFrameLowering::assignCalleeSavedSpillSlots(
20212021
MachineFunction &MF, const TargetRegisterInfo *TRI,
20222022
std::vector<CalleeSavedInfo> &CSI, unsigned &MinCSFrameIndex,
20232023
unsigned &MaxCSFrameIndex) const {
2024+
auto *RVFI = MF.getInfo<RISCVMachineFunctionInfo>();
2025+
2026+
// Preemptible Interrupts have two additional Callee-save Frame Indexes,
2027+
// not tracked by `CSI`.
2028+
if (RVFI->isSiFivePreemptibleInterrupt(MF)) {
2029+
for (int I = 0; I < 2; ++I) {
2030+
int FI = RVFI->getInterruptCSRFrameIndex(I);
2031+
MinCSFrameIndex = std::min<unsigned>(MinCSFrameIndex, FI);
2032+
MaxCSFrameIndex = std::max<unsigned>(MaxCSFrameIndex, FI);
2033+
}
2034+
}
2035+
20242036
// Early exit if no callee saved registers are modified!
20252037
if (CSI.empty())
20262038
return true;
20272039

2028-
auto *RVFI = MF.getInfo<RISCVMachineFunctionInfo>();
20292040
if (RVFI->useQCIInterrupt(MF)) {
20302041
RVFI->setQCIInterruptStackSize(QCIInterruptPushAmount);
20312042
} else if (RVFI->isPushable(MF)) {

0 commit comments

Comments
 (0)