This is the mail archive of the
mailing list for the GCC project.
Proposed AAPCS update - parameter passing types with modified alignments
- From: Richard Earnshaw <Richard dot Earnshaw at foss dot arm dot com>
- To: gcc at gcc dot gnu dot org
- Cc: Alan Lawrence <Alan dot Lawrence at arm dot com>
- Date: Fri, 03 Jul 2015 15:37:45 +0100
- Subject: Proposed AAPCS update - parameter passing types with modified alignments
- Authentication-results: sourceware.org; auth=none
Since it may take some time before an official update to the ARM AAPCS
document can be made, I'm publishing a proposed change here for advanced
notice. Alan will follow up with some GCC patches shortly to implement
The proposed changes should deal with types that have been either
under-aligned (packed) or over-aligned by language extensions or
language defined alignment modifiers. They work by assuming that the
values passed to a procedure are *copies* of values and that these
copies can safely have alignments that differ from both the source of
the copy and also from the target use inside the called procedure (in
the latter case a second copy to suitably aligned memory might be
Since the ABI has not previously defined rules for parameter passing of
values with alignment modifiers it is possible that existing
implementations will not be 100% compatible with all these rules.
Modifying the compiler to conform may result in a silent code-generation
change. (There should be no change for types that are naturally
aligned). We believe this should be very rare and because the ABI has
not previously sanctioned such types they are unlikely to appear at
shared library boundaries. It may help if compilers could emit a
warning should they detect that a parameter may cause such change in
Definitions used in this description:
An Alignment-Adjusted type is a type to which a language alignment
modifier has been applied.
The Member Alignment of an element of an aggregate type is the
alignment of that member /after/ the application of any language
alignment modifiers to that member.
The Natural Alignment of an aggregate type is the maximum of each of
the Member Alignments of the 'top-level' members of the aggregate
type (ie before any alignment adjustment of the entire aggregate is
The Natural Alignment of all fundamental data types is that specified
in Table 1 of the AAPCS.
For the purposes of passing alignment-adjusted types as parameters,
the following rules are proposed as additions to Stage B of Section
5.5 of the AAPCS:
* Values of alignment-adjusted types passed as parameters are /copies/
of the actual values used in the call list.
* The copies have alignments defined as follows:
- For fundamental types, the alignment is the natural alignment of
that type (after any promotions).
- For aggregate types the copy of the aggregate type has 4-byte
alignment if its natural alignment is <= 4 and 8-byte alignment if
its natural alignment is >=8.
* The alignment of the copy is used for applying the argument
Similar changes will be published for AArch64, except that the lower and
upper bounds for the natural alignment checks are are changed from (4,8)
to (8, 16) bytes.