Skip to content

Commit

Permalink
pulley: Fix prologue for large stack frames
Browse files Browse the repository at this point in the history
This fixes a mistake from bytecodealliance#9999 which was discovered in the testing
of bytecodealliance#9837 where the prologue was generated in the wrong order.
  • Loading branch information
alexcrichton committed Jan 14, 2025
1 parent 2ba60e4 commit bc1d2ba
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cranelift/codegen/src/isa/pulley_shared/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,10 @@ where
match &style {
FrameStyle::None => {}
FrameStyle::PulleyBasicSetup { frame_size } => {
insts.push(RawInst::PushFrame.into());
insts.extend(Self::gen_sp_reg_adjust(
-i32::try_from(*frame_size).unwrap(),
));
insts.push(RawInst::PushFrame.into());
}
FrameStyle::PulleySetupAndSaveClobbers {
frame_size,
Expand Down
37 changes: 37 additions & 0 deletions cranelift/filetests/filetests/isa/pulley64/call.clif
Original file line number Diff line number Diff line change
Expand Up @@ -383,3 +383,40 @@ block0:
; pop_frame_restore 64,
; ret

function %very_large_stack_frame(i32) -> i32 {
fn0 = colocated %g() -> i32
ss0 = explicit_slot 1000000

block0(v0: i32):
v1 = call fn0()
v2 = iadd v0, v1
return v2
}

; VCode:
; push_frame
; stack_alloc32 1000016
; xstore64 sp+1000008, x20 // flags = notrap aligned
; block0:
; xmov x20, x0
; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }], clobbers: PRegSet { bits: [65534, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 }
; xmov x5, x20
; xadd32 x0, x5, x0
; x20 = xload64 sp+1000008 // flags = notrap aligned
; stack_free32 1000016
; pop_frame
; ret
;
; Disassembled:
; push_frame
; stack_alloc32 1000016
; xstore64le_offset32 sp, 1000008, x20
; xmov x20, x0
; call 0x0 // target = 0x10
; xmov x5, x20
; xadd32 x0, x5, x0
; xload64le_offset32 x20, sp, 1000008
; stack_free32 1000016
; pop_frame
; ret

0 comments on commit bc1d2ba

Please sign in to comment.