https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98734

            Bug ID: 98734
           Summary: ABI diagnostics emitted despite always_inline
                    attribute
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: e...@coeus-group.com
  Target Milestone: ---

On POWER, I get a lot of "note: the ABI of passing aggregates with 16-byte
alignment has changed in GCC 5" diagnostics unless I pass -Wno-psabi to the
compiler.  This happens even if all the functions which accept the offending
type are also annotated with __attribute__((__always_inline__)) static inline. 
Not even a '#pragma GCC diagnostic ignored "-Wpsabi"' can disable it.

Here is a quick example:

  #include <stdint.h>

  typedef struct {
    int32_t i32 __attribute__((__aligned__(16)));
  } vec;

  #pragma GCC diagnostic ignored "-Wpsabi"

  __attribute__((__always_inline__))
  static inline vec
  add_i32x4 (vec a, vec b) {
    vec r;
    r.i32 = a.i32 + b.i32;
    return r;
  }

  void
  foo (int32_t r[4], int32_t a[4], int32_t b[4]) {
    vec va, vb, vr;
    __builtin_memcpy(&va, a, sizeof(va));
    __builtin_memcpy(&vb, b, sizeof(vb));
    vr = add_i32x4(va, vb);
    __builtin_memcpy(r, &vr, sizeof(vr));
  }

$ gcc -mcpu=power8 -c -o psabi.o psabi.c
psabi.c: In function ‘add_i32x4’:
psabi.c:11:1: note: the ABI of passing aggregates with 16-byte alignment has
changed in GCC 5
   11 | add_i32x4 (vec a, vec b) {
      | ^~~~~~~~~

Ideally, I don't think this should be emitted if the ABI isn't publicly exposed
(i.e., if the function is static, or always_inline.  It would also be good if
it could be disabled with a pragma-.  Finally, the diagnostic message itself
should really mention that it is triggered by -Wpsabi so people don't have to
use Google to figure out what to do to work around the issue.

Reply via email to