yann@1
|
1 |
--- /dev/null Sat Dec 14 13:56:51 2002
|
yann@1
|
2 |
+++ gcc-3.3.1/gcc/testsuite/gcc.dg/pr11736-1.c Sun Sep 14 14:26:33 2003
|
yann@1
|
3 |
@@ -0,0 +1,45 @@
|
yann@1
|
4 |
+/* PR optimization/11736
|
yann@1
|
5 |
+ * Reporter: marcus@mc.pp.se
|
yann@1
|
6 |
+ * Summary: Stackpointer messed up on SuperH
|
yann@1
|
7 |
+ * Keywords: wrong-code
|
yann@1
|
8 |
+ * Description:
|
yann@1
|
9 |
+ * When a function with 5 arguments is called in both branches of a
|
yann@1
|
10 |
+ * conditional, and only the last argument differs, the code to push that
|
yann@1
|
11 |
+ * last argument on the stack gets confused.
|
yann@1
|
12 |
+ * Space for the fifth argument is reserved on the stack by the
|
yann@1
|
13 |
+ * instruction I have marked as "A". However, if the else-branch is
|
yann@1
|
14 |
+ * taken the stackpointer is decremented _again_ at "B". This
|
yann@1
|
15 |
+ * decrementation is never restored, and it is only due to the
|
yann@1
|
16 |
+ * restoration of r15 from r14 that the function works at all. With
|
yann@1
|
17 |
+ * -fomit-frame-pointer it will crash.
|
yann@1
|
18 |
+ *
|
yann@1
|
19 |
+ * Testcase tweaked by dank@kegel.com
|
yann@1
|
20 |
+ * Not marked as xfail since it's a regression from hardhat 2.0 gcc-2.97
|
yann@1
|
21 |
+ * and dodes gcc-3.0.2
|
yann@1
|
22 |
+ */
|
yann@1
|
23 |
+
|
yann@1
|
24 |
+/* { dg-do run } */
|
yann@1
|
25 |
+/* { dg-options "-O1 -fomit-frame-pointer" } */
|
yann@1
|
26 |
+
|
yann@1
|
27 |
+int expected_e;
|
yann@1
|
28 |
+
|
yann@1
|
29 |
+void bar(int a, int b, int c, int d, int e)
|
yann@1
|
30 |
+{
|
yann@1
|
31 |
+ if (e != expected_e)
|
yann@1
|
32 |
+ abort();
|
yann@1
|
33 |
+}
|
yann@1
|
34 |
+
|
yann@1
|
35 |
+void foo(int a)
|
yann@1
|
36 |
+{
|
yann@1
|
37 |
+ if (a)
|
yann@1
|
38 |
+ bar(0, 0, 0, 0, 1);
|
yann@1
|
39 |
+ else
|
yann@1
|
40 |
+ bar(0, 0, 0, 0, 0); /* stack pointer decremented extra time here, causing segfault */
|
yann@1
|
41 |
+}
|
yann@1
|
42 |
+
|
yann@1
|
43 |
+int main(int argc, char **argv)
|
yann@1
|
44 |
+{
|
yann@1
|
45 |
+ for (expected_e = 0; expected_e < 2; expected_e++)
|
yann@1
|
46 |
+ foo(expected_e);
|
yann@1
|
47 |
+ return 0;
|
yann@1
|
48 |
+}
|