This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Add a C testcase for an ARM stack alignment bug.
- From: kazu at codesourcery dot com (Kazu Hirata)
- To: gcc-patches at gcc dot gnu dot org
- Cc: andrew at codesourcery dot com
- Cc: janis187 at us dot ibm dot com
- Date: Thu, 19 Feb 2009 11:33:38 -0800 (PST)
- Subject: [patch] Add a C testcase for an ARM stack alignment bug.
Hi,
Attached is a patch to add a C testcase for an ARM stack alignment bug.
Andrew committed the following to fix a Fortran bug a while ago.
2008-07-30 Andrew Jenner <andrew@codesourcery.com>
* config/arm/arm.c (arm_compute_static_chain_stack_bytes): New
function.
(arm_compute_initial_elimination_offset): Use it.
(arm_compute_save_reg_mask): Include static chain save slot when
calculating alignment.
(arm_get_frame_offsets): Ditto.
(thumb1_compute_save_reg_mask): Ensure we have a low register saved
that we can use to decrement the stack when the stack decrement
could be too big for an immediate value in a single insn.
(thumb1_expand_prologue): Avoid using r12 for stack decrement.
It turns out that there is a C testcase that would be broken without
his patch.
Since C is presumably tested more often than Fortran, I'd like to
propose that the attached testcase be included in the C testsuite.
Tested on arm-none-linux-gnueabi. OK to apply?
Kazu Hirata
2009-02-19 Kazu Hirata <kazu@codesourcery.com>
* gcc.c-torture/execute/20090219-1.c: New.
Index: gcc/testsuite/gcc.c-torture/execute/20090219-1.c
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/20090219-1.c (revision 0)
+++ gcc/testsuite/gcc.c-torture/execute/20090219-1.c (revision 0)
@@ -0,0 +1,29 @@
+/* On ARM, BAR used to get a bogus number in E due to stack
+ misalignment. */
+
+extern void abort (void);
+extern void exit (int);
+
+void
+foo (void)
+{
+ int f = 0;
+
+ void bar (int a, int b, int c, int d, int e)
+ {
+ if (e != 0)
+ {
+ f = 1;
+ abort ();
+ }
+ }
+
+ bar (0, 0, 0, 0, 0);
+}
+
+int
+main (void)
+{
+ foo ();
+ exit (0);
+}