]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
20000906.c: New test.
authorGreg McGary <greg@mcgary.org>
Wed, 6 Sep 2000 08:27:44 +0000 (08:27 +0000)
committerGreg McGary <gkm@gcc.gnu.org>
Wed, 6 Sep 2000 08:27:44 +0000 (08:27 +0000)
* gcc.c-torture/20000906.c: New test.
* gcc.c-torture/20000906.x: Expect failure for ix86 at `-O2'.

From-SVN: r36186

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20000906-1.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/20000906-1.x [new file with mode: 0644]

index f5ca385c4d10afda38e6af732205ecb3bed1117a..53778d8e8bc66fc4e709caeba350a6de7122cdd7 100644 (file)
@@ -1,3 +1,8 @@
+2000-09-06  Greg McGary  <greg@mcgary.org>
+
+       * gcc.c-torture/20000906.c: New test.
+       * gcc.c-torture/20000906.x: Expect failure for ix86 at `-O2'.
+
 2000-09-05  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * gcc.dg/wtr-int-type-1.c: Fix for 64-bit platforms.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20000906-1.c b/gcc/testsuite/gcc.c-torture/execute/20000906-1.c
new file mode 100644 (file)
index 0000000..8665f1b
--- /dev/null
@@ -0,0 +1,76 @@
+/* Testcase distilled from glibc's nss_parse_service_list in nss/nsswitch.c
+   It can't be distilled further.  Fails with `-O2' for i[3456]86.  */
+
+/* this simulates a bounded-pointer type.  */
+struct ucharp { unsigned char *v, *l, *h; };
+
+/* this simulates bounded-pointer check prior to pointer dereference.  */
+#define AREF(var, idx) ((((((((var).v+(idx)) < (var).l) \
+                          || (((var).v+(idx)+1) > (var).h))) \
+                         && (__builtin_trap (), 0)), \
+                        (var).v)[(idx)])
+
+struct list
+{
+  struct list *next;
+};
+
+struct list *
+alloc_list (void)
+{
+  static struct list l;
+  return &l;
+}
+
+int one = 1;
+
+void
+foo (struct ucharp cp, struct ucharp lp, struct list **nextp)
+{
+  while (1)
+    {
+      struct list *list;
+      while (AREF (lp, 0) && AREF (cp, AREF (lp, 0)))
+        ++lp.v;
+      list = alloc_list ();
+      while (AREF (cp, AREF (lp, 0)))
+        ++lp.v;
+      if (AREF (lp, 0) == one)
+       do
+         ++lp.v;
+       while (AREF (lp, 0) && AREF (cp, AREF (lp, 0)));
+      /* The above AREF (cp, ...) fails because the pseudo created to
+        hold cp.v holds garbage, having never been set.
+        The easiest way to see the problem is to compile wiht `-O2 -da'
+        then look at *.09.loop.  Search for something like this:
+
+        Hoisted regno 183 r/o from (mem/s:SI (reg:SI 16 argp) 10)
+          Replaced reg 91, deleting init_insn (213).
+
+        Now, look for the use of reg 91, which has no set.  */
+
+      *nextp = list;
+      nextp = &list->next;
+      if (!*lp.v)
+       break;
+    }
+}
+
+extern void exit (int);
+
+int
+main (void)
+{
+  static unsigned char cp0[] = "\0\0\0\0";
+  struct ucharp cp = { cp0, cp0, cp0 + sizeof (cp0) };
+
+  static unsigned char lp0[] = "\1\1\0\0";
+  struct ucharp lp = { lp0, lp0, lp0 + sizeof (lp0) };
+
+  struct list list;
+  struct list *nextp = &list;
+
+  foo (cp, lp, &nextp);
+
+  exit (0);
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/20000906-1.x b/gcc/testsuite/gcc.c-torture/execute/20000906-1.x
new file mode 100644 (file)
index 0000000..c567fd6
--- /dev/null
@@ -0,0 +1,14 @@
+# This only fails for `-O2', but not `-O3' or `-Os'
+# as I had expected.   See clues in testcase source file.
+
+set torture_eval_before_execute {
+
+    set compiler_conditional_xfail_data {
+        "loop optimizer leaves dangling pseudo" \
+       "i?86-*-*" \
+       { "-O2" } \
+       { "" }
+       }
+}
+
+return 0