1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00
llvm-mirror/test/CodeGen/AVR/calling-conv/c/stack.ll
Ayke van Laethem 684b1f2b77 [AVR] Fix stack size in functions with a frame pointer
This patch fixes a bug in stack save/restore code. Because the frame
pointer was saved/restored manually (not by marking it as clobbered) the
StackSize variable was not updated accordingly. Most code still worked,
but code that tried to load a parameter passed on the stack did not.

This commit fixes this by marking the frame pointer as a
callee-clobbered register. This will let it be saved without any effort
in prolog/epilog code and will make sure the correct address is
calculated for loading parameters that are passed on the stack.

This approach is used by most other targets (such as X86, AArch64 and
RISC-V).

Differential Revision: https://reviews.llvm.org/D78579
2020-06-16 13:53:32 +02:00

33 lines
961 B
LLVM

; RUN: llc < %s -march=avr | FileCheck %s
; CHECK-LABEL: ret_void_args_i64_i64_i32
define void @ret_void_args_i64_i64_i32(i64 %a, i64 %b, i32 %c) {
; We're goign to clobber PTRREG Y
; CHECK: push r28
; CHECK-NEXT: push r29
; Load the stack pointer into Y.
; CHECK-NEXT: in r28, 61
; CHECK-NEXT: in r29, 62
; Load the top two bytes from the 32-bit int.
; CHECK-NEXT: ldd r24, Y+7
; CHECK-NEXT: ldd r25, Y+8
; Store the top two bytes of the 32-bit int to memory.
; CHECK-NEXT: sts 7, r25
; CHECK-NEXT: sts 6, r24
; Load the bottom two bytes from the 32-bit int.
; CHECK-NEXT: ldd r24, Y+5
; CHECK-NEXT: ldd r25, Y+6
; Store the bottom two bytes of the 32-bit int to memory.
; CHECK-NEXT: sts 5, r25
; CHECK-NEXT: sts 4, r24
; Restore PTRREG Y
; CHECK-NEXT: pop r29
; CHECK-NEXT: pop r28
store volatile i32 %c, i32* inttoptr (i64 4 to i32*)
ret void
}