Skip to content

Commit 9041f46

Browse files
committed
fixup! [RISCV] RISCV vector calling convention (1/2)
1 parent 8fa50a0 commit 9041f46

File tree

3 files changed

+7
-34
lines changed

3 files changed

+7
-34
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5440,7 +5440,7 @@ def RISCVVectorCCDocs : Documentation {
54405440
The ``riscv_vector_cc`` attribute can be applied to a function. It preserves 15
54415441
registers namely, v1-v7 and v24-v31 as callee-saved. Callers thus don't need
54425442
to save these registers before function calls, and callees only need to save
5443-
them only if they use them.
5443+
them if they use them.
54445444
}];
54455445
}
54465446

clang/test/CodeGen/RISCV/riscv-vector-callingconv.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// REQUIRES: riscv-registered-target
21
// RUN: %clang_cc1 %s -triple riscv64 -target-feature +v -verify
32

43
__attribute__((riscv_vector_cc)) int var; // expected-warning {{'riscv_vector_cc' only applies to function types; type here is 'int'}}

llvm/lib/Target/RISCV/RISCVFrameLowering.cpp

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ void RISCVFrameLowering::emitPrologue(MachineFunction &MF,
640640
// directives.
641641
for (const auto &Entry : CSI) {
642642
int FrameIdx = Entry.getFrameIdx();
643-
if (FrameIdx >=0 &&
643+
if (FrameIdx >= 0 &&
644644
MFI.getStackID(FrameIdx) == TargetStackID::ScalableVector)
645645
continue;
646646

@@ -1651,37 +1651,11 @@ bool RISCVFrameLowering::restoreCalleeSavedRegisters(
16511651
DL = MI->getDebugLoc();
16521652

16531653
// Manually restore values not restored by libcall & Push/Pop.
1654-
// Keep the same order as in the prologue. There is no need to reverse the
1655-
// order in the epilogue. In addition, the return address will be restored
1656-
// first in the epilogue. It increases the opportunity to avoid the
1657-
// load-to-use data hazard between loading RA and return by RA.
1658-
// loadRegFromStackSlot can insert multiple instructions.
1659-
//
1660-
//
1661-
// We first change the restore order for scalar and vector
1662-
// callee-saved registers as the layout shown below:
1663-
//
1664-
// Epilog restore order (original):
1665-
// ----------------------------
1666-
// RVV objects
1667-
// ----------------------------
1668-
// Callee-saved regs(scalar)
1669-
// Callee-saved regs(vector)
1670-
// ----------------------------
1671-
//
1672-
// Epilog restore order (after):
1673-
// ----------------------------
1674-
// RVV objects
1675-
// ----------------------------
1676-
// Callee-saved regs(vector)
1677-
// Callee-saved regs(scalar)
1678-
// ----------------------------
1679-
//
1680-
// So that it is able to put all vector registers which need
1681-
// to be restored together. The return address will be restored
1682-
// first in the scalar regs. It increases the opportunity to avoid the
1683-
// load-to-use data hazard between loading RA and return by RA.
1684-
// loadRegFromStackSlot can insert multiple instructions.
1654+
// Reverse the restore order in epilog. In addition, the return
1655+
// address will be restored first in the epilogue. It increases
1656+
// the opportunity to avoid the load-to-use data hazard between
1657+
// loading RA and return by RA. loadRegFromStackSlot can insert
1658+
// multiple instructions.
16851659
const auto &UnmanagedCSI = getUnmanagedCSI(*MF, CSI);
16861660
const auto &RVVCSI = getRVVCalleeSavedInfo(*MF, CSI);
16871661

0 commit comments

Comments
 (0)