[PATCH] D46013: [ARM] Conform to AAPCS when passing overaligned composites as arguments

Momchil Velikov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 24 07:58:45 PDT 2018


chill created this revision.
chill added reviewers: john.brawn, olista01, eli.friedman, rengolin.
Herald added a reviewer: javed.absar.
Herald added subscribers: chrib, kristof.beyls.

The "Procedure Call Procedure Call Standard for the ARMĀ®  Architecture" (https://static.docs.arm.com/ihi0042/f/IHI0042F_aapcs.pdf), specifies that composite types are passed  according to their natural alignment:

> 5.5 Parameter Passing
>  ...
>  B.5 If the argument is an alignment adjusted type its value is passed as a copy of the actual value. The
>  copy will have an alignment defined as follows.
> 
> - For a Fundamental Data Type, the alignment is the natural alignment of that type, after any promotions
> - For a Composite Type, the alignment of the copy will have 4-byte alignment if its natural alignment is <= 4 and 8-byte alignment if its natural alignment is >= 8

The "natural alignment" is defined as the maximum of the alignment of the top-level components:

> 4.3 Composite Types
>  ...
> 
> - The natural alignment of a composite type is the maximum of each of the member alignments of the 'top-level' members of the composite type i.e. before any alignment adjustment of the entire composite is applied

`clang`,  however, uses the actual alignment of the composite, instead of the natural alignment.

This patch fixes passing of composite types to use the natural alignment.  With this patch `clang` conforms to AAPCS and is compatible with GCC.


Repository:
  rC Clang

https://reviews.llvm.org/D46013

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/RecordLayout.h
  lib/AST/ASTContext.cpp
  lib/AST/RecordLayout.cpp
  lib/AST/RecordLayoutBuilder.cpp
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/aapcs-align.cc
  test/CodeGen/arm-arguments.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46013.143742.patch
Type: text/x-patch
Size: 16678 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180424/1cfbc1ed/attachment.bin>


More information about the cfe-commits mailing list