Skip to content

Commit 9c93dd2

Browse files
committed
[llvm] Set ScalableVector stack id in proper place
Without this patch ScalableVector frame index property is used before assignment. More precisely, let's take a look at RISCVFrameLowering::assignCalleeSavedSpillSlots. In this function we divide callee saved registers on scalar and vector ones, based on ScalableVector property of their frame indexes: ``` ... const auto &UnmanagedCSI = getUnmanagedCSI(*MF, CSI); const auto &RVVCSI = getRVVCalleeSavedInfo(*MF, CSI); ... ``` But we assign ScalableVector property several lines below: ``` ... auto storeRegToStackSlot = [&](decltype(UnmanagedCSI) CSInfo) { for (auto &CS : CSInfo) { // Insert the spill to the stack frame. Register Reg = CS.getReg(); const TargetRegisterClass *RC = TRI->getMinimalPhysRegClass(Reg); TII.storeRegToStackSlot(MBB, MI, Reg, !MBB.isLiveIn(Reg), CS.getFrameIdx(), RC, TRI, Register()); } }; storeRegToStackSlot(UnmanagedCSI); ... ``` Due to it, list of RVV callee saved registers will always be empty. Currently this problem doesn't appear, but if you slightly change the code and, for example, put some instructions between scalar and vector spills, the resulting code will be ill formed.
1 parent e21ab4d commit 9c93dd2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

llvm/lib/Target/RISCV/RISCVFrameLowering.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,8 @@ bool RISCVFrameLowering::assignCalleeSavedSpillSlots(
16071607
int FrameIdx = MFI.CreateFixedSpillStackObject(Size, Offset);
16081608
assert(FrameIdx < 0);
16091609
CS.setFrameIdx(FrameIdx);
1610+
if (RISCVRegisterInfo::isRVVRegClass(RC))
1611+
MFI.setStackID(FrameIdx, TargetStackID::ScalableVector);
16101612
continue;
16111613
}
16121614
}
@@ -1623,6 +1625,8 @@ bool RISCVFrameLowering::assignCalleeSavedSpillSlots(
16231625
if ((unsigned)FrameIdx > MaxCSFrameIndex)
16241626
MaxCSFrameIndex = FrameIdx;
16251627
CS.setFrameIdx(FrameIdx);
1628+
if (RISCVRegisterInfo::isRVVRegClass(RC))
1629+
MFI.setStackID(FrameIdx, TargetStackID::ScalableVector);
16261630
}
16271631

16281632
// Allocate a fixed object that covers the full push or libcall size.

0 commit comments

Comments
 (0)