mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
d98e321d12
When we pass a AArch64 Homogeneous Floating-Point Aggregate (HFA) argument with increased alignment requirements, for example struct S { __attribute__ ((__aligned__(16))) double v[4]; }; Clang uses `[4 x double]` for the parameter, which is passed on the stack at alignment 8, whereas it should be at alignment 16, following Rule C.4 in AAPCS (https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#642parameter-passing-rules) Currently we don't have a way to express in LLVM IR the alignment requirements of the function arguments. The align attribute is applicable to pointers only, and only for some special ways of passing arguments (e..g byval). When implementing AAPCS32/AAPCS64, clang resorts to dubious hacks of coercing to types, which naturally have the needed alignment. We don't have enough types to cover all the cases, though. This patch introduces a new use of the stackalign attribute to control stack slot alignment, when and if an argument is passed in memory. The attribute align is left as an optimizer hint - it still applies to pointer types only and pertains to the content of the pointer, whereas the alignment of the pointer itself is determined by the stackalign attribute. For byval arguments, the stackalign attribute assumes the role, previously perfomed by align, falling back to align if stackalign` is absent. On the clang side, when passing arguments using the "direct" style (cf. `ABIArgInfo::Kind`), now we can optionally specify an alignment, which is emitted as the new `stackalign` attribute. Patch by Momchil Velikov and Lucas Prates. Differential Revision: https://reviews.llvm.org/D98794
34 lines
1.3 KiB
LLVM
34 lines
1.3 KiB
LLVM
; RUN: llc < %s -mtriple=arm64-none-eabi | FileCheck %s
|
|
|
|
; Over-aligned HFA argument placed on register - one element per register
|
|
define double @test_hfa_align_arg_reg([2 x double] alignstack(16) %h.coerce) local_unnamed_addr #0 {
|
|
entry:
|
|
; CHECK-LABEL: test_hfa_align_arg_reg:
|
|
; CHECK-NOT: mov
|
|
; CHECK-NOT: ld
|
|
; CHECK: ret
|
|
%h.coerce.fca.0.extract = extractvalue [2 x double] %h.coerce, 0
|
|
ret double %h.coerce.fca.0.extract
|
|
}
|
|
|
|
; Call with over-aligned HFA argument placed on register - one element per register
|
|
define double @test_hfa_align_call_reg() local_unnamed_addr #0 {
|
|
entry:
|
|
; CHECK-LABEL: test_hfa_align_call_reg:
|
|
; CHECK-DAG: fmov d0, #1.00000000
|
|
; CHECK-DAG: fmov d1, #2.00000000
|
|
; CHECK: bl test_hfa_align_arg_reg
|
|
%call = call double @test_hfa_align_arg_reg([2 x double] alignstack(16) [double 1.000000e+00, double 2.000000e+00])
|
|
ret double %call
|
|
}
|
|
|
|
; Over-aligned HFA argument placed on stack - stack round up to alignment
|
|
define double @test_hfa_align_arg_stack(double %d0, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, double %d7, float %f, [2 x double] alignstack(16) %h.coerce) local_unnamed_addr #0 {
|
|
entry:
|
|
; CHECK-LABEL: test_hfa_align_arg_stack:
|
|
; CHECK: ldr d0, [sp, #16]
|
|
; CHECK-NEXT: ret
|
|
%h.coerce.fca.0.extract = extractvalue [2 x double] %h.coerce, 0
|
|
ret double %h.coerce.fca.0.extract
|
|
}
|