OSDN Git Service

* ipa-cp.c (ipcp_versionable_function_p): Walk cgraph edges instead of
[pf3gnuchains/gcc-fork.git] / gcc / ipa-struct-reorg.c
index bef303e..460c23f 100644 (file)
@@ -1,5 +1,5 @@
 /* Struct-reorg optimization.
-   Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Olga Golovanevsky <olga@il.ibm.com>
    (Initial version of this code was developed
    by Caroline Tice and Mostafa Hagog.)
@@ -447,9 +447,7 @@ decompose_access (tree str_decl, struct field_access_site *acc)
 static inline struct field_access_site *
 make_field_acc_node (void)
 {
-  int size = sizeof (struct field_access_site);
-
-  return (struct field_access_site *) xcalloc (1, size);
+  return XCNEW (struct field_access_site);
 }
 
 /* This function returns the structure field access, defined by STMT,
@@ -495,15 +493,18 @@ add_access_to_acc_sites (gimple stmt, tree var, htab_t accs)
      {
        void **slot;
 
-       acc = (struct access_site *) xmalloc (sizeof (struct access_site));
+       acc = XNEW (struct access_site);
        acc->stmt = stmt;
-       acc->vars = VEC_alloc (tree, heap, 10);
+       if (!is_gimple_debug (stmt))
+        acc->vars = VEC_alloc (tree, heap, 10);
+       else
+        acc->vars = NULL;
        slot = htab_find_slot_with_hash (accs, stmt,
                                        htab_hash_pointer (stmt), INSERT);
        *slot = acc;
-
      }
-   VEC_safe_push (tree, heap, acc->vars, var);
+   if (!is_gimple_debug (stmt))
+     VEC_safe_push (tree, heap, acc->vars, var);
 }
 
 /* This function adds NEW_DECL to function
@@ -1383,6 +1384,14 @@ create_new_general_access (struct access_site *acc, d_str str)
       create_new_stmts_for_cond_expr (stmt);
       break;
 
+    case GIMPLE_DEBUG:
+      /* It is very hard to maintain usable debug info after struct peeling,
+        for now just reset all debug stmts referencing objects that have
+        been peeled.  */
+      gimple_debug_bind_reset_value (stmt);
+      update_stmt (stmt);
+      break;
+
     default:
       create_new_stmts_for_general_acc (acc, str);
     }
@@ -1990,7 +1999,7 @@ create_new_var_node (tree var, d_str str)
 {
   new_var node;
 
-  node = (new_var) xmalloc (sizeof (struct new_var_data));
+  node = XNEW (struct new_var_data);
   node->orig_var = var;
   node->new_vars = VEC_alloc (tree, heap, VEC_length (tree, str->new_types));
   return node;
@@ -2331,8 +2340,7 @@ get_fields (tree struct_decl, int num_fields)
   tree t = TYPE_FIELDS (struct_decl);
   int idx = 0;
 
-  list =
-    (struct field_entry *) xmalloc (num_fields * sizeof (struct field_entry));
+  list = XNEWVEC (struct field_entry, num_fields);
 
   for (idx = 0 ; t; t = TREE_CHAIN (t), idx++)
     if (TREE_CODE (t) == FIELD_DECL)
@@ -2494,6 +2502,15 @@ get_stmt_accesses (tree *tp, int *walk_subtrees, void *data)
 
        if (i != VEC_length (structure, structures))
          {
+           if (is_gimple_debug (stmt))
+             {
+               d_str str;
+
+               str = VEC_index (structure, structures, i);
+               add_access_to_acc_sites (stmt, NULL, str->accs);
+               *walk_subtrees = 0;
+               break;
+             }
            if (dump_file)
              {
                fprintf (dump_file, "\nThe type ");
@@ -2525,6 +2542,13 @@ get_stmt_accesses (tree *tp, int *walk_subtrees, void *data)
                struct field_entry * field =
                  find_field_in_struct (str, field_decl);
 
+               if (is_gimple_debug (stmt))
+                 {
+                   add_access_to_acc_sites (stmt, NULL, str->accs);
+                   *walk_subtrees = 0;
+                   break;
+                 }
+
                if (field)
                  {
                    struct field_access_site *acc = make_field_acc_node ();
@@ -3012,8 +3036,7 @@ add_alloc_site (tree fn_decl, gimple stmt, d_str str)
     {
       void **slot;
 
-      fallocs = (fallocs_t)
-       xmalloc (sizeof (struct func_alloc_sites));
+      fallocs = XNEW (struct func_alloc_sites);
       fallocs->func = fn_decl;
       fallocs->allocs = VEC_alloc (alloc_site_t, heap, 1);
       slot = htab_find_slot_with_hash (alloc_sites, fn_decl,
@@ -3168,10 +3191,8 @@ collect_accesses_in_bb (basic_block bb)
 static void
 gen_cluster (sbitmap fields, d_str str)
 {
-  struct field_cluster *crr_cluster = NULL;
+  struct field_cluster *crr_cluster = XCNEW (struct field_cluster);
 
-  crr_cluster =
-    (struct field_cluster *) xcalloc (1, sizeof (struct field_cluster));
   crr_cluster->sibling = str->struct_clustering;
   str->struct_clustering = crr_cluster;
   crr_cluster->fields_in_cluster = fields;
@@ -3182,10 +3203,8 @@ gen_cluster (sbitmap fields, d_str str)
 static void
 peel_field (int i, d_str ds)
 {
-  struct field_cluster *crr_cluster = NULL;
+  struct field_cluster *crr_cluster = XCNEW (struct field_cluster);
 
-  crr_cluster =
-    (struct field_cluster *) xcalloc (1, sizeof (struct field_cluster));
   crr_cluster->sibling = ds->struct_clustering;
   ds->struct_clustering = crr_cluster;
   crr_cluster->fields_in_cluster =
@@ -3222,6 +3241,7 @@ do_reorg_for_func (struct cgraph_node *node)
   create_new_accesses_for_func ();
   update_ssa (TODO_update_ssa);
   cleanup_tree_cfg ();
+  cgraph_rebuild_references ();
 
   /* Free auxiliary data representing local variables.  */
   free_new_vars_htab (new_local_vars);