Skip to content

Revert "[RISCV] Allow spilling to unused Zcmp Stack (#125959)" #137060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1795,15 +1795,10 @@ bool RISCVFrameLowering::assignCalleeSavedSpillSlots(
MFI.CreateFixedSpillStackObject(
QCIInterruptPushAmount, -static_cast<int64_t>(QCIInterruptPushAmount));
} else if (RVFI->isPushable(MF)) {
// Allocate a fixed object that covers all the registers that are pushed.
if (unsigned PushedRegs = RVFI->getRVPushRegs()) {
int64_t PushedRegsBytes =
static_cast<int64_t>(PushedRegs) * (STI.getXLen() / 8);
MFI.CreateFixedSpillStackObject(PushedRegsBytes, -PushedRegsBytes);
}
// Allocate a fixed object that covers the full push.
if (int64_t PushSize = RVFI->getRVPushStackSize())
MFI.CreateFixedSpillStackObject(PushSize, -PushSize);
} else if (int LibCallRegs = getLibCallID(MF, CSI) + 1) {
// Allocate a fixed object that covers all of the stack allocated by the
// libcall.
int64_t LibCallFrameSize =
alignTo((STI.getXLen() / 8) * LibCallRegs, getStackAlign());
MFI.CreateFixedSpillStackObject(LibCallFrameSize, -LibCallFrameSize);
Expand Down
236 changes: 118 additions & 118 deletions llvm/test/CodeGen/RISCV/callee-saved-gprs.ll

Large diffs are not rendered by default.

1,024 changes: 516 additions & 508 deletions llvm/test/CodeGen/RISCV/push-pop-popret.ll

Large diffs are not rendered by default.

36 changes: 22 additions & 14 deletions llvm/test/CodeGen/RISCV/rvv/rv32-spill-vector-csr.ll
Original file line number Diff line number Diff line change
Expand Up @@ -108,35 +108,39 @@ define <vscale x 1 x double> @foo(<vscale x 1 x double> %a, <vscale x 1 x double
;
; SPILL-O2-ZCMP-LABEL: foo:
; SPILL-O2-ZCMP: # %bb.0:
; SPILL-O2-ZCMP-NEXT: cm.push {ra, s0}, -16
; SPILL-O2-ZCMP-NEXT: .cfi_def_cfa_offset 16
; SPILL-O2-ZCMP-NEXT: cm.push {ra, s0}, -32
; SPILL-O2-ZCMP-NEXT: .cfi_def_cfa_offset 32
; SPILL-O2-ZCMP-NEXT: .cfi_offset ra, -8
; SPILL-O2-ZCMP-NEXT: .cfi_offset s0, -4
; SPILL-O2-ZCMP-NEXT: csrr a1, vlenb
; SPILL-O2-ZCMP-NEXT: slli a1, a1, 1
; SPILL-O2-ZCMP-NEXT: sub sp, sp, a1
; SPILL-O2-ZCMP-NEXT: .cfi_escape 0x0f, 0x0d, 0x72, 0x00, 0x11, 0x10, 0x22, 0x11, 0x02, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # sp + 16 + 2 * vlenb
; SPILL-O2-ZCMP-NEXT: .cfi_escape 0x0f, 0x0d, 0x72, 0x00, 0x11, 0x20, 0x22, 0x11, 0x02, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # sp + 32 + 2 * vlenb
; SPILL-O2-ZCMP-NEXT: mv s0, a0
; SPILL-O2-ZCMP-NEXT: vs1r.v v8, (sp) # vscale x 8-byte Folded Spill
; SPILL-O2-ZCMP-NEXT: addi a1, sp, 16
; SPILL-O2-ZCMP-NEXT: vs1r.v v8, (a1) # vscale x 8-byte Folded Spill
; SPILL-O2-ZCMP-NEXT: vsetvli zero, a0, e64, m1, ta, ma
; SPILL-O2-ZCMP-NEXT: vfadd.vv v9, v8, v9
; SPILL-O2-ZCMP-NEXT: csrr a0, vlenb
; SPILL-O2-ZCMP-NEXT: add a0, a0, sp
; SPILL-O2-ZCMP-NEXT: addi a0, a0, 16
; SPILL-O2-ZCMP-NEXT: vs1r.v v9, (a0) # vscale x 8-byte Folded Spill
; SPILL-O2-ZCMP-NEXT: lui a0, %hi(.L.str)
; SPILL-O2-ZCMP-NEXT: addi a0, a0, %lo(.L.str)
; SPILL-O2-ZCMP-NEXT: call puts
; SPILL-O2-ZCMP-NEXT: csrr a0, vlenb
; SPILL-O2-ZCMP-NEXT: add a0, a0, sp
; SPILL-O2-ZCMP-NEXT: addi a0, a0, 16
; SPILL-O2-ZCMP-NEXT: vl1r.v v8, (a0) # vscale x 8-byte Folded Reload
; SPILL-O2-ZCMP-NEXT: vl1r.v v9, (sp) # vscale x 8-byte Folded Reload
; SPILL-O2-ZCMP-NEXT: addi a0, sp, 16
; SPILL-O2-ZCMP-NEXT: vl1r.v v9, (a0) # vscale x 8-byte Folded Reload
; SPILL-O2-ZCMP-NEXT: vsetvli zero, s0, e64, m1, ta, ma
; SPILL-O2-ZCMP-NEXT: vfadd.vv v8, v9, v8
; SPILL-O2-ZCMP-NEXT: csrr a0, vlenb
; SPILL-O2-ZCMP-NEXT: slli a0, a0, 1
; SPILL-O2-ZCMP-NEXT: add sp, sp, a0
; SPILL-O2-ZCMP-NEXT: .cfi_def_cfa sp, 16
; SPILL-O2-ZCMP-NEXT: cm.popret {ra, s0}, 16
; SPILL-O2-ZCMP-NEXT: .cfi_def_cfa sp, 32
; SPILL-O2-ZCMP-NEXT: cm.popret {ra, s0}, 32
;
; SPILL-O0-VSETVLI-LABEL: foo:
; SPILL-O0-VSETVLI: # %bb.0:
Expand Down Expand Up @@ -227,33 +231,37 @@ define <vscale x 1 x double> @foo(<vscale x 1 x double> %a, <vscale x 1 x double
;
; SPILL-O2-ZCMP-VSETVLI-LABEL: foo:
; SPILL-O2-ZCMP-VSETVLI: # %bb.0:
; SPILL-O2-ZCMP-VSETVLI-NEXT: cm.push {ra, s0}, -16
; SPILL-O2-ZCMP-VSETVLI-NEXT: .cfi_def_cfa_offset 16
; SPILL-O2-ZCMP-VSETVLI-NEXT: cm.push {ra, s0}, -32
; SPILL-O2-ZCMP-VSETVLI-NEXT: .cfi_def_cfa_offset 32
; SPILL-O2-ZCMP-VSETVLI-NEXT: .cfi_offset ra, -8
; SPILL-O2-ZCMP-VSETVLI-NEXT: .cfi_offset s0, -4
; SPILL-O2-ZCMP-VSETVLI-NEXT: vsetvli a1, zero, e8, m2, ta, ma
; SPILL-O2-ZCMP-VSETVLI-NEXT: sub sp, sp, a1
; SPILL-O2-ZCMP-VSETVLI-NEXT: .cfi_escape 0x0f, 0x0d, 0x72, 0x00, 0x11, 0x10, 0x22, 0x11, 0x02, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # sp + 16 + 2 * vlenb
; SPILL-O2-ZCMP-VSETVLI-NEXT: .cfi_escape 0x0f, 0x0d, 0x72, 0x00, 0x11, 0x20, 0x22, 0x11, 0x02, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # sp + 32 + 2 * vlenb
; SPILL-O2-ZCMP-VSETVLI-NEXT: mv s0, a0
; SPILL-O2-ZCMP-VSETVLI-NEXT: vs1r.v v8, (sp) # vscale x 8-byte Folded Spill
; SPILL-O2-ZCMP-VSETVLI-NEXT: addi a1, sp, 16
; SPILL-O2-ZCMP-VSETVLI-NEXT: vs1r.v v8, (a1) # vscale x 8-byte Folded Spill
; SPILL-O2-ZCMP-VSETVLI-NEXT: vsetvli zero, a0, e64, m1, ta, ma
; SPILL-O2-ZCMP-VSETVLI-NEXT: vfadd.vv v9, v8, v9
; SPILL-O2-ZCMP-VSETVLI-NEXT: csrr a0, vlenb
; SPILL-O2-ZCMP-VSETVLI-NEXT: add a0, a0, sp
; SPILL-O2-ZCMP-VSETVLI-NEXT: addi a0, a0, 16
; SPILL-O2-ZCMP-VSETVLI-NEXT: vs1r.v v9, (a0) # vscale x 8-byte Folded Spill
; SPILL-O2-ZCMP-VSETVLI-NEXT: lui a0, %hi(.L.str)
; SPILL-O2-ZCMP-VSETVLI-NEXT: addi a0, a0, %lo(.L.str)
; SPILL-O2-ZCMP-VSETVLI-NEXT: call puts
; SPILL-O2-ZCMP-VSETVLI-NEXT: csrr a0, vlenb
; SPILL-O2-ZCMP-VSETVLI-NEXT: add a0, a0, sp
; SPILL-O2-ZCMP-VSETVLI-NEXT: addi a0, a0, 16
; SPILL-O2-ZCMP-VSETVLI-NEXT: vl1r.v v8, (a0) # vscale x 8-byte Folded Reload
; SPILL-O2-ZCMP-VSETVLI-NEXT: vl1r.v v9, (sp) # vscale x 8-byte Folded Reload
; SPILL-O2-ZCMP-VSETVLI-NEXT: addi a0, sp, 16
; SPILL-O2-ZCMP-VSETVLI-NEXT: vl1r.v v9, (a0) # vscale x 8-byte Folded Reload
; SPILL-O2-ZCMP-VSETVLI-NEXT: vsetvli zero, s0, e64, m1, ta, ma
; SPILL-O2-ZCMP-VSETVLI-NEXT: vfadd.vv v8, v9, v8
; SPILL-O2-ZCMP-VSETVLI-NEXT: vsetvli a0, zero, e8, m2, ta, ma
; SPILL-O2-ZCMP-VSETVLI-NEXT: add sp, sp, a0
; SPILL-O2-ZCMP-VSETVLI-NEXT: .cfi_def_cfa sp, 16
; SPILL-O2-ZCMP-VSETVLI-NEXT: cm.popret {ra, s0}, 16
; SPILL-O2-ZCMP-VSETVLI-NEXT: .cfi_def_cfa sp, 32
; SPILL-O2-ZCMP-VSETVLI-NEXT: cm.popret {ra, s0}, 32
{
%x = call <vscale x 1 x double> @llvm.riscv.vfadd.nxv1f64.nxv1f64(<vscale x 1 x double> undef, <vscale x 1 x double> %a, <vscale x 1 x double> %b, i32 7, i32 %gvl)
%call = call signext i32 @puts(ptr @.str)
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/CodeGen/RISCV/xqccmp-additional-stack.ll
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ define ptr @func(ptr %s, i32 %_c, ptr %incdec.ptr, i1 %0, i8 %conv14) #0 {
; RV32-NEXT: .cfi_offset ra, -4
; RV32-NEXT: .cfi_offset s0, -8
; RV32-NEXT: .cfi_offset s1, -12
; RV32-NEXT: addi sp, sp, -4
; RV32-NEXT: .cfi_def_cfa_offset 20
; RV32-NEXT: addi sp, sp, -8
; RV32-NEXT: .cfi_def_cfa_offset 24
; RV32-NEXT: sw a4, 4(sp) # 4-byte Folded Spill
; RV32-NEXT: sw a2, 0(sp) # 4-byte Folded Spill
; RV32-NEXT: mv a2, a1
Expand All @@ -34,7 +34,7 @@ define ptr @func(ptr %s, i32 %_c, ptr %incdec.ptr, i1 %0, i8 %conv14) #0 {
; RV32-NEXT: lw a0, 4(sp) # 4-byte Folded Reload
; RV32-NEXT: sb a0, 0(s0)
; RV32-NEXT: mv a0, s1
; RV32-NEXT: addi sp, sp, 4
; RV32-NEXT: addi sp, sp, 8
; RV32-NEXT: .cfi_def_cfa_offset 16
; RV32-NEXT: qc.cm.popret {ra, s0-s1}, 16
entry:
Expand Down
Loading
Loading