mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-22 23:31:32 +00:00
b52ba9f8a8
Stack is formed improperly for long structures passed as byval arguments for EABI mode. If we took AAPCS reference, we can found the next statements: A: "If the argument requires double-word alignment (8-byte), the NCRN (Next Core Register Number) is rounded up to the next even register number." (5.5 Parameter Passing, Stage C, C.3). B: "The alignment of an aggregate shall be the alignment of its most-aligned component." (4.3 Composite Types, 4.3.1 Aggregates). So if we have structure with doubles (9 double fields) and 3 Core unused registers (r1, r2, r3): caller should use r2 and r3 registers only. Currently r1,r2,r3 set is used, but it is invalid. Callee VA routine should also use r2 and r3 regs only. All is ok here. This behaviour is guessed by rounding up SP address with ADD+BFC operations. Fix: Main fix is in ARMTargetLowering::HandleByVal. If we detected AAPCS mode and 8 byte alignment, we waste odd registers then. P.S.: I also improved LDRB_POST_IMM regression test. Since ldrb instruction will not generated by current regression test after this patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166018 91177308-0d34-0410-b5e6-96231b3b80d8
17 lines
510 B
LLVM
17 lines
510 B
LLVM
; RUN: llc < %s -mtriple=armv7-none-linux- | FileCheck %s
|
|
; Check that LDRB_POST_IMM instruction emitted properly.
|
|
|
|
%my_struct_t = type { i8, i8, i8, i8, i8 }
|
|
@main.val = private unnamed_addr constant %my_struct_t { i8 1, i8 2, i8 3, i8 4, i8 5 }
|
|
|
|
declare void @f(i32 %n1, i32 %n2, i32 %n3, %my_struct_t* byval %val);
|
|
|
|
; CHECK: main:
|
|
define i32 @main() nounwind {
|
|
entry:
|
|
; CHECK: ldrb {{(r[0-9]+)}}, {{(\[r[0-9]+\])}}, #1
|
|
call void @f(i32 555, i32 555, i32 555, %my_struct_t* byval @main.val)
|
|
ret i32 0
|
|
}
|
|
|