mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-29 10:32:47 +00:00
083bc97344
Introduction: In case when stack alignment is 8 and GPRs parameter part size is not N*8: we add padding to GPRs part, so part's last byte must be recovered at address K*8-1. We need to do it, since remained (stack) part of parameter starts from address K*8, and we need to "attach" "GPRs head" without gaps to it: Stack: |---- 8 bytes block ----| |---- 8 bytes block ----| |---- 8 bytes... [ [padding] [GPRs head] ] [ ------ Tail passed via stack ------ ... FIX: Note, once we added padding we need to correct *all* Arg offsets that are going after padded one. That's why we need this fix: Arg offsets were never corrected before this patch. See new test-cases included in patch. We also don't need to insert padding for byval parameters that are stored in GPRs only. We need pad only last byval parameter and only in case it outsides GPRs and stack alignment = 8. Though, stack area, allocated for recovered byval params, must satisfy "Size mod 8 = 0" restriction. This patch reduces stack usage for some cases: We can reduce ArgRegsSaveArea since inner N*4 bytes sized byval params my be "packed" with alignment 4 in some cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182237 91177308-0d34-0410-b5e6-96231b3b80d8
74 lines
1.4 KiB
LLVM
74 lines
1.4 KiB
LLVM
;PR15293: ARM codegen ice - expected larger existing stack allocation
|
|
;RUN: llc -mtriple=arm-linux-gnueabihf < %s | FileCheck %s
|
|
|
|
;CHECK: foo:
|
|
;CHECK: sub sp, sp, #8
|
|
;CHECK: push {r11, lr}
|
|
;CHECK: str r0, [sp, #8]
|
|
;CHECK: add r0, sp, #8
|
|
;CHECK: bl fooUseParam
|
|
;CHECK: pop {r11, lr}
|
|
;CHECK: add sp, sp, #8
|
|
;CHECK: mov pc, lr
|
|
|
|
;CHECK: foo2:
|
|
;CHECK: sub sp, sp, #8
|
|
;CHECK: push {r11, lr}
|
|
;CHECK: str r0, [sp, #8]
|
|
;CHECK: add r0, sp, #8
|
|
;CHECK: str r2, [sp, #12]
|
|
;CHECK: bl fooUseParam
|
|
;CHECK: add r0, sp, #12
|
|
;CHECK: bl fooUseParam
|
|
;CHECK: pop {r11, lr}
|
|
;CHECK: add sp, sp, #8
|
|
;CHECK: mov pc, lr
|
|
|
|
;CHECK: doFoo:
|
|
;CHECK: push {r11, lr}
|
|
;CHECK: ldr r0,
|
|
;CHECK: ldr r0, [r0]
|
|
;CHECK: bl foo
|
|
;CHECK: pop {r11, lr}
|
|
;CHECK: mov pc, lr
|
|
|
|
|
|
;CHECK: doFoo2:
|
|
;CHECK: push {r11, lr}
|
|
;CHECK: ldr r0,
|
|
;CHECK: mov r1, #0
|
|
;CHECK: ldr r0, [r0]
|
|
;CHECK: mov r2, r0
|
|
;CHECK: bl foo2
|
|
;CHECK: pop {r11, lr}
|
|
;CHECK: mov pc, lr
|
|
|
|
|
|
%artz = type { i32 }
|
|
@static_val = constant %artz { i32 777 }
|
|
|
|
declare void @fooUseParam(%artz* )
|
|
|
|
define void @foo(%artz* byval %s) {
|
|
call void @fooUseParam(%artz* %s)
|
|
ret void
|
|
}
|
|
|
|
define void @foo2(%artz* byval %s, i32 %p, %artz* byval %s2) {
|
|
call void @fooUseParam(%artz* %s)
|
|
call void @fooUseParam(%artz* %s2)
|
|
ret void
|
|
}
|
|
|
|
|
|
define void @doFoo() {
|
|
call void @foo(%artz* byval @static_val)
|
|
ret void
|
|
}
|
|
|
|
define void @doFoo2() {
|
|
call void @foo2(%artz* byval @static_val, i32 0, %artz* byval @static_val)
|
|
ret void
|
|
}
|
|
|