OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / ipa-type-escape.c
index 289598d..b2ee148 100644 (file)
@@ -1,5 +1,5 @@
 /* Type based alias analysis.
-   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
    Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
 
 This file is part of GCC.
@@ -16,8 +16,8 @@ for more details.
 
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING.  If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.  */
+Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA.  */
 
 /* This pass determines which types in the program contain only
    instances that are completely encapsulated by the compilation unit.
@@ -200,56 +200,57 @@ compare_type_brand (splay_tree_key sk1, splay_tree_key sk2)
 static tree
 discover_unique_type (tree type)
 {
-  struct type_brand_s * brand = xmalloc(sizeof(struct type_brand_s));
+  struct type_brand_s * brand = XNEW (struct type_brand_s);
   int i = 0;
   splay_tree_node result;
-  
+
+  brand->name = get_name_of_type (type);
+
   while (1)
-  {
-    brand->name = get_name_of_type (type);
-    brand->seq = i;
-    result = splay_tree_lookup (all_canon_types, (splay_tree_key) brand);
-    if (result)
-      {
-       /* Create an alias since this is just the same as
-          other_type.  */
-       tree other_type = (tree) result->value;
-       if (lang_hooks.types_compatible_p (type, other_type) == 1)
-         {
-           free (brand);
-           /* Insert this new type as an alias for other_type.  */
-           splay_tree_insert (type_to_canon_type, 
-                              (splay_tree_key) type,
-                              (splay_tree_value) other_type);
-           return other_type;
-         }
-       /* Not compatible, look for next instance with same name.  */
-      }
-    else 
-      {
-       /* No more instances, create new one since this is the first
-          time we saw this type.  */
-       brand->seq = i++;
-       /* Insert the new brand.  */
-       splay_tree_insert (all_canon_types, 
-                          (splay_tree_key) brand,
-                          (splay_tree_value) type);      
-       
-       /* Insert this new type as an alias for itself.  */
-       splay_tree_insert (type_to_canon_type, 
-                          (splay_tree_key) type,
-                          (splay_tree_value) type);
-
-       /* Insert the uid for reverse lookup; */
-       splay_tree_insert (uid_to_canon_type, 
-                          (splay_tree_key) TYPE_UID (type),
-                          (splay_tree_value) type);      
-
-       bitmap_set_bit (global_types_seen, TYPE_UID (type));
-       return type;
-      }
-    i++;
-  } 
+    {
+      brand->seq = i++;
+      result = splay_tree_lookup (all_canon_types, (splay_tree_key) brand);
+
+      if (result)
+       {
+         /* Create an alias since this is just the same as
+            other_type.  */
+         tree other_type = (tree) result->value;
+         if (lang_hooks.types_compatible_p (type, other_type) == 1)
+           {
+             free (brand);
+             /* Insert this new type as an alias for other_type.  */
+             splay_tree_insert (type_to_canon_type,
+                                (splay_tree_key) type,
+                                (splay_tree_value) other_type);
+             return other_type;
+           }
+         /* Not compatible, look for next instance with same name.  */
+       }
+      else
+       {
+         /* No more instances, create new one since this is the first
+            time we saw this type.  */
+         brand->seq = i++;
+         /* Insert the new brand.  */
+         splay_tree_insert (all_canon_types,
+                            (splay_tree_key) brand,
+                            (splay_tree_value) type);
+
+         /* Insert this new type as an alias for itself.  */
+         splay_tree_insert (type_to_canon_type,
+                            (splay_tree_key) type,
+                            (splay_tree_value) type);
+
+         /* Insert the uid for reverse lookup; */
+         splay_tree_insert (uid_to_canon_type,
+                            (splay_tree_key) TYPE_UID (type),
+                            (splay_tree_value) type);
+
+         bitmap_set_bit (global_types_seen, TYPE_UID (type));
+         return type;
+       }
+    }
 }
 
 /* Return true if TYPE is one of the type classes that we are willing
@@ -266,7 +267,6 @@ type_to_consider (tree type)
   switch (TREE_CODE (type))
     {
     case BOOLEAN_TYPE:
-    case CHAR_TYPE:
     case COMPLEX_TYPE:
     case ENUMERAL_TYPE:
     case INTEGER_TYPE:
@@ -394,7 +394,7 @@ ipa_type_escape_type_contained_p (tree type)
                        get_canon_type_uid (type, true, false));
 }
 
-/* Return true a modification to a field of type FIELD_TYPE cannot
+/* Return true if a modification to a field of type FIELD_TYPE cannot
    clobber a record of RECORD_TYPE.  */
 
 bool 
@@ -487,7 +487,7 @@ mark_type (tree type, enum escape_t escape_status)
       bitmap_set_bit (map, uid);
       if (escape_status == FULL_ESCAPE)
        {
-         /* Effeciency hack. When things are bad, do not mess around
+         /* Efficiency hack. When things are bad, do not mess around
             with this type anymore.  */
          bitmap_set_bit (global_types_exposed_parameter, uid);
        }      
@@ -1348,13 +1348,10 @@ analyze_variable (struct cgraph_varpool_node *vnode)
   if (vnode->externally_visible)
     mark_interesting_type (type, FULL_ESCAPE);
 
-  if (TREE_CODE (global) == VAR_DECL)
-    {
-      if (DECL_INITIAL (global)) 
-       walk_tree (&DECL_INITIAL (global), scan_for_refs, 
-                  NULL, visited_nodes);
-    } 
-  else abort();
+  gcc_assert (TREE_CODE (global) == VAR_DECL);
+
+  if (DECL_INITIAL (global))
+    walk_tree (&DECL_INITIAL (global), scan_for_refs, NULL, visited_nodes);
 }
 
 /* This is the main routine for finding the reference patterns for
@@ -1461,7 +1458,7 @@ close_type_seen (tree type)
     return;
   bitmap_set_bit (been_there_done_that, uid);
 
-  /* If we are doing a language with a type heirarchy, mark all of
+  /* If we are doing a language with a type hierarchy, mark all of
      the superclasses.  */
   if (TYPE_BINFO (type)) 
     for (binfo = TYPE_BINFO (type), i = 0;
@@ -1568,7 +1565,7 @@ close_type_full_escape (tree type)
 
   subtype_map = subtype_map_for_uid (uid, false);
 
-  /* If we are doing a language with a type heirarchy, mark all of
+  /* If we are doing a language with a type hierarchy, mark all of
      the superclasses.  */
   if (TYPE_BINFO (type)) 
     for (binfo = TYPE_BINFO (type), i = 0;
@@ -1622,7 +1619,7 @@ close_type_full_escape (tree type)
 }
 
 /* Transitively close the addressof bitmap for the type with UID.
-   This means that if we had a.b and b.c, a would have both b an c in
+   This means that if we had a.b and b.c, a would have both b and c in
    its maps.  */ 
 
 static bitmap
@@ -1673,7 +1670,7 @@ close_addressof_down (int uid)
 \f
 /* The main entry point for type escape analysis.  */
 
-static void
+static unsigned int
 type_escape_execute (void)
 {
   struct cgraph_node *node;
@@ -1775,9 +1772,6 @@ type_escape_execute (void)
       result = splay_tree_successor (all_canon_types, (splay_tree_key) key);
     }
 
-/*   { */
-/*     FILE * tmp = dump_file; */
-/*     dump_file = stderr; */
   if (dump_file)
     { 
       EXECUTE_IF_SET_IN_BITMAP (global_types_seen, 0, i, bi)
@@ -1794,8 +1788,6 @@ type_escape_execute (void)
            fprintf(dump_file, " contained\n");
        }
     }
-/*   dump_file = tmp; */
-/*   } */
 
   /* Get rid of uid_to_addressof_up_map and its bitmaps.  */
   result = splay_tree_min (uid_to_addressof_up_map);
@@ -1825,6 +1817,7 @@ type_escape_execute (void)
   BITMAP_FREE (been_there_done_that);
   BITMAP_FREE (bitmap_tmp);
   BITMAP_FREE (results_of_malloc);
+  return 0;
 }
 
 static bool