/* Intel MCU psABI specifies scalar types > 4 bytes aligned to 4
bytes. */
- mode = TYPE_MODE (strip_array_types (type));
+ type = strip_array_types (type);
+ if (TYPE_ATOMIC (type))
+ return align;
+
+ mode = TYPE_MODE (type);
switch (GET_MODE_CLASS (mode))
{
case MODE_INT:
&& align == 64
&& ix86_preferred_stack_boundary < 64
&& (mode == DImode || (type && TYPE_MODE (type) == DImode))
- && (!type || !TYPE_USER_ALIGN (type))
+ && (!type || (!TYPE_USER_ALIGN (type)
+ && !TYPE_ATOMIC (strip_array_types (type))))
&& (!decl || !DECL_USER_ALIGN (decl)))
align = 32;
/* Don't do dynamic stack realignment for long long objects with
-mpreferred-stack-boundary=2. */
if ((mode == DImode || (type && TYPE_MODE (type) == DImode))
- && (!type || !TYPE_USER_ALIGN (type))
+ && (!type || (!TYPE_USER_ALIGN (type)
+ && !TYPE_ATOMIC (strip_array_types (type))))
&& (!decl || !DECL_USER_ALIGN (decl)))
{
gcc_checking_assert (!TARGET_STV);
return computed;
if (TARGET_IAMCU)
return iamcu_alignment (type, computed);
- mode = TYPE_MODE (strip_array_types (type));
+ type = strip_array_types (type);
+ mode = TYPE_MODE (type);
if (mode == DFmode || mode == DCmode
|| GET_MODE_CLASS (mode) == MODE_INT
|| GET_MODE_CLASS (mode) == MODE_COMPLEX_INT)
- return MIN (32, computed);
+ {
+ if (TYPE_ATOMIC (type) && computed > 32)
+ {
+ static bool warned;
+
+ if (!warned && warn_psabi)
+ {
+ const char *url
+ = CHANGES_ROOT_URL "gcc-11/changes.html#ia32_atomic";
+
+ warned = true;
+ inform (input_location, "the alignment of %<_Atomic %T%> "
+ "fields changed in %{GCC 11.1%}",
+ TYPE_MAIN_VARIANT (type), url);
+ }
+ }
+ else
+ return MIN (32, computed);
+ }
return computed;
}
--- /dev/null
+/* PR target/65146 */
+/* { dg-do compile } */
+/* { dg-options "-Wno-psabi" } */
+
+struct A { char a; _Atomic long long b; };
+struct B { char a; _Atomic double b; };
+struct C { char a; _Atomic long long b[2]; };
+struct D { char a; _Atomic double b[2]; };
+extern int a[__builtin_offsetof (struct A, b) == 8 ? 1 : -1];
+extern int b[__builtin_offsetof (struct B, b) == 8 ? 1 : -1];
+extern int c[__builtin_offsetof (struct C, b) == 8 ? 1 : -1];
+extern int d[__builtin_offsetof (struct D, b) == 8 ? 1 : -1];