OSDN Git Service

2009-05-12 Paolo Bonzini <bonzini@gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / tree-ssa.c
index ba0c6ab..10f8482 100644 (file)
@@ -834,7 +834,6 @@ delete_tree_ssa (void)
            {
              gimple_set_def_ops (stmt, NULL);
              gimple_set_use_ops (stmt, NULL);
-             gimple_set_addresses_taken (stmt, NULL);
            }
 
          if (gimple_has_mem_ops (stmt))
@@ -845,7 +844,8 @@ delete_tree_ssa (void)
 
          gimple_set_modified (stmt, true);
        }
-      set_phi_nodes (bb, NULL);
+      if (!(bb->flags & BB_RTL))
+       set_phi_nodes (bb, NULL);
     }
 
   /* Remove annotations from every referenced local variable.  */
@@ -961,12 +961,9 @@ useless_type_conversion_p_1 (tree outer_type, tree inner_type)
          && TYPE_VOLATILE (TREE_TYPE (outer_type)))
        return false;
 
-      /* Do not lose casts between pointers with different
-        TYPE_REF_CAN_ALIAS_ALL setting or alias sets.  */
-      if ((TYPE_REF_CAN_ALIAS_ALL (inner_type)
-          != TYPE_REF_CAN_ALIAS_ALL (outer_type))
-         || (get_alias_set (TREE_TYPE (inner_type))
-             != get_alias_set (TREE_TYPE (outer_type))))
+      /* Do not lose casts between pointers that when dereferenced access
+        memory with different alias sets.  */
+      if (get_deref_alias_set (inner_type) != get_deref_alias_set (outer_type))
        return false;
 
       /* We do not care for const qualification of the pointed-to types
@@ -1002,6 +999,13 @@ useless_type_conversion_p_1 (tree outer_type, tree inner_type)
       if (TREE_CODE (inner_type) != TREE_CODE (outer_type))
        return false;
 
+      /* Conversions from array types with unknown extent to
+        array types with known extent are not useless.  */
+      if (TREE_CODE (inner_type) == ARRAY_TYPE
+         && !TYPE_DOMAIN (inner_type)
+         && TYPE_DOMAIN (outer_type))
+       return false;
+
       /* ???  This seems to be necessary even for aggregates that don't
         have TYPE_STRUCTURAL_EQUALITY_P set.  */
 
@@ -1457,7 +1461,7 @@ struct gimple_opt_pass pass_early_warn_uninitialized =
   NULL,                                        /* sub */
   NULL,                                        /* next */
   0,                                   /* static_pass_number */
-  0,                                   /* tv_id */
+  TV_NONE,                             /* tv_id */
   PROP_ssa,                            /* properties_required */
   0,                                   /* properties_provided */
   0,                                   /* properties_destroyed */
@@ -1476,7 +1480,7 @@ struct gimple_opt_pass pass_late_warn_uninitialized =
   NULL,                                        /* sub */
   NULL,                                        /* next */
   0,                                   /* static_pass_number */
-  0,                                   /* tv_id */
+  TV_NONE,                             /* tv_id */
   PROP_ssa,                            /* properties_required */
   0,                                   /* properties_provided */
   0,                                   /* properties_destroyed */
@@ -1504,25 +1508,30 @@ execute_update_addresses_taken (bool do_optimize)
     {
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
        {
-         const_gimple stmt = gsi_stmt (gsi);
+         gimple stmt = gsi_stmt (gsi);
          enum gimple_code code = gimple_code (stmt);
-         bitmap taken = gimple_addresses_taken (stmt);
-         
-         if (taken)
-           bitmap_ior_into (addresses_taken, taken);
-         
+
+         /* Note all addresses taken by the stmt.  */
+         gimple_ior_addresses_taken (addresses_taken, stmt);
+
          /* 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 (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
            {
-             tree lhs = gimple_get_lhs (stmt);
-             /* A plain decl does not need it set.  */
-             if (lhs && handled_component_p (lhs))
-               {
-                 var = get_base_address (lhs);
-                 if (DECL_P (var))
-                   bitmap_set_bit (not_reg_needs, DECL_UID (var));
-               }
+              tree lhs = gimple_get_lhs (stmt);
+              
+              /* We may not rewrite TMR_SYMBOL to SSA.  */
+              if (lhs && TREE_CODE (lhs) == TARGET_MEM_REF
+                  && TMR_SYMBOL (lhs))
+                bitmap_set_bit (not_reg_needs, DECL_UID (TMR_SYMBOL (lhs)));
+
+              /* A plain decl does not need it set.  */
+              else if (lhs && handled_component_p (lhs))
+                {
+                  var = get_base_address (lhs);
+                  if (DECL_P (var))
+                    bitmap_set_bit (not_reg_needs, DECL_UID (var));
+                }
            }
        }
 
@@ -1574,7 +1583,9 @@ execute_update_addresses_taken (bool do_optimize)
        if (!DECL_GIMPLE_REG_P (var)
            && !bitmap_bit_p (not_reg_needs, DECL_UID (var))
            && (TREE_CODE (TREE_TYPE (var)) == COMPLEX_TYPE
-               || TREE_CODE (TREE_TYPE (var)) == VECTOR_TYPE))
+               || TREE_CODE (TREE_TYPE (var)) == VECTOR_TYPE)
+           && !TREE_THIS_VOLATILE (var)
+           && (TREE_CODE (var) != VAR_DECL || !DECL_HARD_REGISTER (var)))
          {
            DECL_GIMPLE_REG_P (var) = 1;
            mark_sym_for_renaming (var);
@@ -1619,7 +1630,7 @@ struct gimple_opt_pass pass_update_address_taken =
   NULL,                                        /* sub */
   NULL,                                        /* next */
   0,                                   /* static_pass_number */
-  0,                                   /* tv_id */
+  TV_NONE,                             /* tv_id */
   PROP_ssa,                            /* properties_required */
   0,                                   /* properties_provided */
   0,                                   /* properties_destroyed */