This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Handle VCE in mf_xform_derefs_1 (PR libmudflap/36397)


Hi!

This patch handles VCE in mf_xform_derefs_1 instead of aborting on it.
If It is a VCE of constant mf_xform_derefs_1 doesn't handle, it won't
be interesting to mudflap anyway, so it just returns immediately instead
of failing assertion in the next iteration.  Otherwise it looks through
the VCE.

Tested on x86_64-linux, ok for trunk?

2008-09-15  Jakub Jelinek  <jakub@redhat.com>

	PR libmudflap/36397
	* tree-mudflap.c (mf_xform_derefs_1): Handle VIEW_CONVERT_EXPR.

	* testsuite/libmudflap.c/pass64-frag.c: New test.

--- gcc/tree-mudflap.c.jj	2008-09-05 12:56:32.000000000 +0200
+++ gcc/tree-mudflap.c	2008-09-15 11:58:08.000000000 +0200
@@ -773,6 +773,13 @@ mf_xform_derefs_1 (gimple_stmt_iterator 
 		base = TREE_OPERAND (var, 0);
                 break;
               }
+            else if (TREE_CODE (var) == VIEW_CONVERT_EXPR)
+	      {
+		var = TREE_OPERAND (var, 0);
+		if (CONSTANT_CLASS_P (var)
+		    && TREE_CODE (var) != STRING_CST)
+		  return;
+	      }
             else 
               {
                 gcc_assert (TREE_CODE (var) == VAR_DECL 
--- libmudflap/testsuite/libmudflap.c/pass64-frag.c.jj	2008-09-15 12:14:28.000000000 +0200
+++ libmudflap/testsuite/libmudflap.c/pass64-frag.c	2008-09-15 12:16:17.000000000 +0200
@@ -0,0 +1,37 @@
+/* PR libmudflap/36397 */
+/* { dg-do run } */
+/* { dg-options "-O -fmudflap -fno-strict-aliasing -lmudflap" } */
+
+struct A
+{
+  int a[2];
+};
+
+long long int x;
+
+int __attribute__ ((noinline))
+baz (long long int *x)
+{
+  return *x;
+}
+
+int __attribute__ ((noinline))
+foo (int i)
+{
+  if (i > 10)
+    return baz (&x);
+  return ((struct A *) &x)->a[i];
+}
+
+int
+main (void)
+{
+  if (sizeof (long long) == 2 * sizeof (int) == sizeof (struct A))
+    {
+      struct A a = { .a[0] = 10, .a[1] = 20 };
+      __builtin_memcpy (&x, &a, sizeof (x));
+      if (foo (0) != 10 || foo (1) != 20)
+        __builtin_abort ();
+    }
+  return 0;
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]