]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end/118684 - fix fallout of wrong stack local alignment fix
authorRichard Biener <rguenther@suse.de>
Wed, 29 Jan 2025 07:58:39 +0000 (08:58 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 29 Jan 2025 09:29:01 +0000 (10:29 +0100)
When we expand BIT_FIELD_REF <x_2(D), 8, 8> we can end up creating
a stack local, running into the fix.  But get_object_alignment
will return 8 for any SSA_NAME because that's not an "object" we
handle.  Deal with handled components on registers by singling out
SSA_NAME bases, using their type alignment instead of
get_object_alignment (I considered "robustifying" get_object_alignment,
but decided not to at this point).

This fixes an ICE on gcc.dg/pr41123.c on arm as reported by the CI.

PR middle-end/118684
* expr.cc (expand_expr_real_1): When creating a stack local
during expansion of a handled component, when the base is
a SSA_NAME use its type alignment and avoid calling
get_object_alignment.

* gcc.dg/pr118684.c: Require automatic_stack_alignment.

gcc/expr.cc
gcc/testsuite/gcc.dg/pr118684.c

index 95f41f69fcf2e114026e440e6b2beaa33de3008b..7f3149b85eec5e48ef574b3fc71ad5f8db54baa4 100644 (file)
@@ -12152,7 +12152,9 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
            if (!poly_int_tree_p (TYPE_SIZE_UNIT (TREE_TYPE (tem)), &size))
              size = max_int_size_in_bytes (TREE_TYPE (tem));
            memloc = assign_stack_local (TYPE_MODE (TREE_TYPE (tem)), size,
-                                        get_object_alignment (tem));
+                                        TREE_CODE (tem) == SSA_NAME
+                                        ? TYPE_ALIGN (TREE_TYPE (tem))
+                                        : get_object_alignment (tem));
            emit_move_insn (memloc, op0);
            op0 = memloc;
            clear_mem_expr = true;
index 08cc24dc0616e4da7f321a53d7d716052dcbb8f7..28fd76e366dcf13da1ce65a94881c213ea25f7e2 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-do run } */
+/* { dg-do run { target automatic_stack_alignment } } */
 /* { dg-options "-O2" } */
 
 typedef int v4si __attribute__((vector_size(16)));