summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/torture/parm-coalesce.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/torture/parm-coalesce.c')
-rw-r--r--gcc/testsuite/gcc.dg/torture/parm-coalesce.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/parm-coalesce.c b/gcc/testsuite/gcc.dg/torture/parm-coalesce.c
new file mode 100644
index 00000000000..dbd81c1ba21
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/parm-coalesce.c
@@ -0,0 +1,40 @@
+/* { dg-do run } */
+
+#include <stdlib.h>
+
+/* Make sure we don't coalesce both incoming parms, one whose incoming
+ value is unused, to the same location, so as to overwrite one of
+ them with the incoming value of the other. */
+
+int __attribute__((noinline, noclone))
+foo (int i, int j)
+{
+ j = i; /* The incoming value for J is unused. */
+ i = 2;
+ if (j)
+ j++;
+ j += i + 1;
+ return j;
+}
+
+/* Same as foo, but with swapped parameters. */
+int __attribute__((noinline, noclone))
+bar (int j, int i)
+{
+ j = i; /* The incoming value for J is unused. */
+ i = 2;
+ if (j)
+ j++;
+ j += i + 1;
+ return j;
+}
+
+int
+main (void)
+{
+ if (foo (0, 1) != 3)
+ abort ();
+ if (bar (1, 0) != 3)
+ abort ();
+ return 0;
+}