OSDN Git Service

2009-01-26 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Jan 2009 09:55:30 +0000 (09:55 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Jan 2009 09:55:30 +0000 (09:55 +0000)
PR tree-optimization/38745
* tree-ssa.c (execute_update_addresses_taken): Do not include
variables that cannot possibly be a register in not_reg_needs.
Do not clear TREE_ADDRESSABLE on vars that may not become
registers.
* tree-ssa.c (update_alias_info_1): Include those in the set
of addressable vars.

* g++.dg/torture/pr38745.C: New testcase.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr38745.C [new file with mode: 0644]
gcc/tree-ssa-alias.c
gcc/tree-ssa.c

index f9ca880..505c99a 100644 (file)
@@ -1,5 +1,15 @@
 2009-01-26  Richard Guenther  <rguenther@suse.de>
 
+       PR tree-optimization/38745
+       * tree-ssa.c (execute_update_addresses_taken): Do not include
+       variables that cannot possibly be a register in not_reg_needs.
+       Do not clear TREE_ADDRESSABLE on vars that may not become
+       registers.
+       * tree-ssa.c (update_alias_info_1): Include those in the set
+       of addressable vars.
+
+2009-01-26  Richard Guenther  <rguenther@suse.de>
+
        PR middle-end/38851
        * Makefile.in (tree-ssa-dse.o): Add langhooks.h.
        * tree-ssa-dse.c: Include langhooks.h
index ea1493a..5743ae0 100644 (file)
@@ -1,5 +1,10 @@
 2009-01-26  Richard Guenther  <rguenther@suse.de>
 
+       PR tree-optimization/38745
+       * g++.dg/torture/pr38745.C: New testcase.
+
+2009-01-26  Richard Guenther  <rguenther@suse.de>
+
        PR middle-end/38851
        * g++.dg/warn/Wuninitialized-1.C: New testcase.
 
diff --git a/gcc/testsuite/g++.dg/torture/pr38745.C b/gcc/testsuite/g++.dg/torture/pr38745.C
new file mode 100644 (file)
index 0000000..4ad9d85
--- /dev/null
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+
+union u_u16
+{
+  unsigned short v;
+  struct
+    {
+      unsigned char lo8, hi8;
+    } __attribute__ ((__may_alias__)) u;
+} __attribute__ ((__may_alias__));
+union u_u32
+{
+  unsigned int v;
+  struct
+    {
+      u_u16 lo16, hi16;
+    } u;
+} __attribute__ ((__may_alias__));
+union u_u64
+{
+  struct
+    {
+      u_u32 lo32, hi32;
+    } u;
+};
+struct Record
+{
+};
+long long
+UnpackFullKey (Record & rec, const char *&p)
+{
+  long long c64 = 0;
+  (*(u_u16 *) & (*(u_u32 *) & ( *(u_u64*)&c64).u.lo32.v).u.lo16.v).u.hi8 = 1;
+  return c64;
+}
+
index 4e9d28b..9ed242d 100644 (file)
@@ -2483,6 +2483,22 @@ update_alias_info_1 (gimple stmt, struct alias_info *ai)
   if (addr_taken)
     bitmap_ior_into (gimple_addressable_vars (cfun), addr_taken);
 
+  /* If we have a call or an assignment, see if the lhs contains
+     a local decl that requires not to be a gimple register.  */
+  if (gimple_code (stmt) == GIMPLE_ASSIGN
+      || gimple_code (stmt) == GIMPLE_CALL)
+    {
+      tree lhs = gimple_get_lhs (stmt);
+      /* A plain decl does not need it set.  */
+      if (lhs && handled_component_p (lhs))
+       {
+         tree var = get_base_address (lhs);
+         if (DECL_P (var)
+             && is_gimple_reg_type (TREE_TYPE (var)))
+           bitmap_set_bit (gimple_addressable_vars (cfun), DECL_UID (var));
+       }
+    }
+
   /* Process each operand use.  For pointers, determine whether they
      are dereferenced by the statement, or whether their value
      escapes, etc.  */
index 935cad6..91cbc19 100644 (file)
@@ -1731,7 +1731,12 @@ execute_update_addresses_taken (void)
          || bitmap_bit_p (addresses_taken, DECL_UID (var)))
        continue;
        
-      if (TREE_ADDRESSABLE (var))
+      if (TREE_ADDRESSABLE (var)
+         /* Do not change TREE_ADDRESSABLE if we need to preserve var as
+            a non-register.  Otherwise we are confused and forget to
+            add virtual operands for it.  */
+         && (!is_gimple_reg_type (TREE_TYPE (var))
+             || !bitmap_bit_p (not_reg_needs, DECL_UID (var))))
        {
          TREE_ADDRESSABLE (var) = 0;
          if (is_gimple_reg (var))