re PR tree-optimization/26626 (ICE in in add_virtual_operand)
authorDaniel Berlin <dberlin@dberlin.org>
Wed, 3 May 2006 03:19:22 +0000 (03:19 +0000)
committerDaniel Berlin <dberlin@gcc.gnu.org>
Wed, 3 May 2006 03:19:22 +0000 (03:19 +0000)
2006-05-02  Daniel Berlin  <dberlin@dberlin.org>

Fix PR tree-optimization/26626
* tree-ssa-structalias.c (compute_points_to_sets): For now, solve
always.
* tree-ssa-operands.c (access_can_touch_variable): Allow
typecasting through union pointers.

From-SVN: r113493

gcc/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr26626.c [new file with mode: 0644]
gcc/tree-ssa-operands.c
gcc/tree-ssa-structalias.c

index 162af2fe98cad0cc6e46e8684583dcbef012cf4d..6e73c304f3453b719a63f89d1f310a74418781e0 100644 (file)
@@ -1,3 +1,11 @@
+2006-05-02  Daniel Berlin  <dberlin@dberlin.org>
+
+       Fix PR tree-optimization/26626
+       * tree-ssa-structalias.c (compute_points_to_sets): For now, solve
+       always.
+       * tree-ssa-operands.c (access_can_touch_variable): Allow
+       typecasting through union pointers.
+
 2006-05-02  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/26943
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr26626.c b/gcc/testsuite/gcc.c-torture/compile/pr26626.c
new file mode 100644 (file)
index 0000000..a4e0301
--- /dev/null
@@ -0,0 +1,13 @@
+typedef union {
+    int d;
+} U;
+
+int rv;
+void breakme()
+{
+    U *rv0;
+    U *pretmp = (U*)&rv;
+    rv0 = pretmp;
+    rv0->d = 42;
+}
+
index e979b4ce65aa5ca3a6b05fd5ebc5c78f2463a7c2..68613fe9564a195ba63fab2aee4b214585a9a0f3 100644 (file)
@@ -1118,11 +1118,32 @@ access_can_touch_variable (tree ref, tree alias, HOST_WIDE_INT offset,
      { return (struct foos *)&foo; }
      
      (taken from 20000623-1.c)
+
+     The docs also say/imply that access through union pointers
+     is legal (but *not* if you take the address of the union member,
+     i.e. the inverse), such that you can do
+
+     typedef union {
+       int d;
+     } U;
+
+     int rv;
+     void breakme()
+     {
+       U *rv0;
+       U *pretmp = (U*)&rv;
+       rv0 = pretmp;
+       rv0->d = 42;    
+     }
+     To implement this, we just punt on accesses through union
+     pointers entirely.
   */
   else if (ref 
           && flag_strict_aliasing
           && TREE_CODE (ref) != INDIRECT_REF
           && !MTAG_P (alias)
+          && (TREE_CODE (base) != INDIRECT_REF
+              || TREE_CODE (TREE_TYPE (base)) != UNION_TYPE)
           && !AGGREGATE_TYPE_P (TREE_TYPE (alias))
           && TREE_CODE (TREE_TYPE (alias)) != COMPLEX_TYPE
           && !POINTER_TYPE_P (TREE_TYPE (alias)))
index 7a00de456117e871021453cc182ea3f826c528b7..c5b6cabaadb965824da65ad0317aa5510b94c8d2 100644 (file)
@@ -4485,7 +4485,7 @@ compute_points_to_sets (struct alias_info *ai)
       dump_constraints (dump_file);
     }
   
-  if (need_to_solve ())
+  if (1 || need_to_solve ())
     {
       if (dump_file)
        fprintf (dump_file,