OSDN Git Service

2010-04-07 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / ipa-reference.c
index 032bef2..9eac3b1 100644 (file)
@@ -1,5 +1,6 @@
 /* Callgraph based analysis of static variables.
-   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2007, 2008, 2009, 2010
+   Free Software Foundation, Inc.
    Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
 
 This file is part of GCC.
@@ -306,7 +307,7 @@ has_proper_scope_for_analysis (tree t)
 {
   /* If the variable has the "used" attribute, treat it as if it had a
      been touched by the devil.  */
-  if (lookup_attribute ("used", DECL_ATTRIBUTES (t)))
+  if (DECL_PRESERVE_P (t))
     return false;
 
   /* Do not want to do anything with volatile except mark any
@@ -351,9 +352,9 @@ static bool
 mark_address (gimple stmt ATTRIBUTE_UNUSED, tree addr,
              void *data ATTRIBUTE_UNUSED)
 {
-  while (handled_component_p (addr))
-    addr = TREE_OPERAND (addr, 0);
-  mark_address_taken (addr);
+  addr = get_base_address (addr);
+  if (addr)
+    mark_address_taken (addr);
   return false;
 }
 
@@ -363,7 +364,8 @@ static bool
 mark_load (gimple stmt ATTRIBUTE_UNUSED, tree t, void *data)
 {
   ipa_reference_local_vars_info_t local = (ipa_reference_local_vars_info_t)data;
-  if (TREE_CODE (t) == VAR_DECL
+  t = get_base_address (t);
+  if (t && TREE_CODE (t) == VAR_DECL
       && has_proper_scope_for_analysis (t))
     bitmap_set_bit (local->statics_read, DECL_UID (t));
   return false;
@@ -375,7 +377,8 @@ static bool
 mark_store (gimple stmt ATTRIBUTE_UNUSED, tree t, void *data)
 {
   ipa_reference_local_vars_info_t local = (ipa_reference_local_vars_info_t)data;
-  if (TREE_CODE (t) == VAR_DECL
+  t = get_base_address (t);
+  if (t && TREE_CODE (t) == VAR_DECL
       && has_proper_scope_for_analysis (t))
     {
       if (local)
@@ -1389,22 +1392,23 @@ propagate (void)
              ipa_reference_local_vars_info_t w_l = w_ri->local;
              fprintf (dump_file, "\n  next cycle: %s/%i ",
                       cgraph_node_name (w), w->uid);
-             fprintf (dump_file, "\n    locals read: ");
-             EXECUTE_IF_SET_IN_BITMAP (w_l->statics_read,
-                                       0, index, bi)
-               {
-                 fprintf (dump_file, "%s ",
-                          get_static_name (index));
-               }
+             fprintf (dump_file, "\n    locals read: ");
+             if (w_l->statics_read)
+               EXECUTE_IF_SET_IN_BITMAP (w_l->statics_read,
+                                         0, index, bi)
+                 {
+                   fprintf (dump_file, "%s ",
+                            get_static_name (index));
+                 }
 
              fprintf (dump_file, "\n    locals written: ");
-             EXECUTE_IF_SET_IN_BITMAP (w_l->statics_written,
-                                       0, index, bi)
-               {
-                 fprintf(dump_file, "%s ",
-                         get_static_name (index));
-               }
-
+             if (w_l->statics_written)
+               EXECUTE_IF_SET_IN_BITMAP (w_l->statics_written,
+                                         0, index, bi)
+                 {
+                   fprintf (dump_file, "%s ",
+                            get_static_name (index));
+                 }
 
              w_info = (struct ipa_dfs_info *) w->aux;
              w = w_info->next_cycle;