OSDN Git Service

PR libmudflap/36397
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 15 Sep 2008 21:52:53 +0000 (21:52 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 15 Sep 2008 21:52:53 +0000 (21:52 +0000)
* tree-mudflap.c (mf_xform_derefs_1): Handle VIEW_CONVERT_EXPR.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140374 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree-mudflap.c
libmudflap/ChangeLog
libmudflap/testsuite/libmudflap.c/pass64-frag.c [new file with mode: 0644]

index eeab0fe..ab5a315 100644 (file)
@@ -1,3 +1,8 @@
+2008-09-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR libmudflap/36397
+       * tree-mudflap.c (mf_xform_derefs_1): Handle VIEW_CONVERT_EXPR.
+
 2008-09-14  Andreas Schwab  <schwab@suse.de>
 
        * tree-call-cdce.c (check_target_format): Accept Motorola formats.
index 3f77b2c..0b3eba5 100644 (file)
@@ -773,6 +773,13 @@ mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp,
                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 
index e9eec10..6a87924 100644 (file)
@@ -1,3 +1,8 @@
+2008-09-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR libmudflap/36397
+       * testsuite/libmudflap.c/pass64-frag.c: New test.
+
 2008-06-17  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * Makefile.in: Regenerate.
diff --git a/libmudflap/testsuite/libmudflap.c/pass64-frag.c b/libmudflap/testsuite/libmudflap.c/pass64-frag.c
new file mode 100644 (file)
index 0000000..856eec0
--- /dev/null
@@ -0,0 +1,38 @@
+/* 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 (long long) == 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;
+}