[PATCH] D75903: [AArch64][CodeGen] Fixing stack alignment of HFA arguments on AArch64 PCS

Oliver Stannard (Linaro) via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 08:07:07 PDT 2020


ostannard added a comment.

I've not looked at the code in detail yet, but I think this still gets the ABI wrong for this example:

  typedef struct {
    __attribute__ ((__aligned__(32))) double v[4];
  } TYPE1;
  
  double func(double d0, double d1, double d2, double d3,
              double d4, double d5, double d6, double d7,
              float stk0, TYPE1 stk1) {
    return stk1.v[0];
  }

The ABI says (https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst, rule 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 8-byte alignment if its natural alignment is <= 8 and 16-byte alignment if its natural alignment is >= 16.
  The alignment of the copy is used for applying marshaling rules.

This means that `stk1` should be passed as a copy with alignment 16 bytes, putting it at `sp+16`. GCC does this, clang without this patch passes it at `sp+8`, and clang with this patch passes it at `sp+32`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75903/new/

https://reviews.llvm.org/D75903





More information about the llvm-commits mailing list