aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/config/aarch64/aarch64.cc15
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr108910.c8
2 files changed, 22 insertions, 1 deletions
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 42617ce..f4ef22c 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -7484,7 +7484,20 @@ aarch64_function_arg_alignment (machine_mode mode, const_tree type,
gcc_assert (TYPE_MODE (type) == mode);
if (!AGGREGATE_TYPE_P (type))
- return TYPE_ALIGN (TYPE_MAIN_VARIANT (type));
+ {
+ /* The ABI alignment is the natural alignment of the type, without
+ any attributes applied. Normally this is the alignment of the
+ TYPE_MAIN_VARIANT, but not always; see PR108910 for a counterexample.
+ For now we just handle the known exceptions explicitly. */
+ type = TYPE_MAIN_VARIANT (type);
+ if (POINTER_TYPE_P (type))
+ {
+ gcc_assert (known_eq (POINTER_SIZE, GET_MODE_BITSIZE (mode)));
+ return POINTER_SIZE;
+ }
+ gcc_assert (!TYPE_USER_ALIGN (type));
+ return TYPE_ALIGN (type);
+ }
if (TREE_CODE (type) == ARRAY_TYPE)
return TYPE_ALIGN (TREE_TYPE (type));
diff --git a/gcc/testsuite/gcc.dg/torture/pr108910.c b/gcc/testsuite/gcc.dg/torture/pr108910.c
new file mode 100644
index 0000000..5973548
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr108910.c
@@ -0,0 +1,8 @@
+extern void foo (float, float *, float *);
+
+void
+bar (void *p)
+{
+ float *__attribute__((aligned (64))) q = __builtin_assume_aligned (p, 64);
+ foo (0.0f, q, q);
+}