OSDN Git Service

PR c++/17868
[pf3gnuchains/gcc-fork.git] / gcc / cgraphunit.c
index 73f5d6c..5d0a32f 100644 (file)
@@ -142,7 +142,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
         ??? Move this to separate file after tree-ssa merge.
 
        We separate inlining decisions from the inliner itself and store it
-       inside callgraph as so called inline plan.  Reffer to cgraph.c
+       inside callgraph as so called inline plan.  Refer to cgraph.c
        documentation about particular representation of inline plans in the
        callgraph
 
@@ -166,7 +166,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 
 /* Additionally this file gathers information about how local statics
-   are used.  This is done in cgraph_charactize_statics.  After the
+   are used.  This is done in cgraph_characterize_statics.  After the
    call graph has been built, each function is analyzed to determine
    which local static variables are either read or written or have
    their address taken.  Any local static that has its address taken
@@ -263,7 +263,7 @@ static tree memory_identifier;
 static bool
 decide_is_function_needed (struct cgraph_node *node, tree decl)
 {
-  struct cgraph_node *origin;
+  tree origin;
 
   /* If we decided it was needed before, but at the time we didn't have
      the body of the function available, then it's still needed.  We have
@@ -303,8 +303,9 @@ decide_is_function_needed (struct cgraph_node *node, tree decl)
     return false;
   /* Nested functions of extern inline function shall not be emit unless
      we inlined the origin.  */
-  for (origin = node->origin; origin; origin = origin->origin)
-    if (DECL_EXTERNAL (origin->decl))
+  for (origin = decl_function_context (decl); origin;
+       origin = decl_function_context (origin))
+    if (DECL_EXTERNAL (origin))
       return false;
   /* We want to emit COMDAT functions only when absolutely necessary.  */
   if (DECL_COMDAT (decl))
@@ -351,18 +352,20 @@ static void
 convert_UIDs_in_bitmap (bitmap in_ann, bitmap in_decl) 
 {
   int index;
-  EXECUTE_IF_SET_IN_BITMAP(in_decl, 0, index,
-      {
-       splay_tree_node n = 
-         splay_tree_lookup (static_vars_to_consider_by_uid, index);
-       if (n != NULL) 
-         {
-           tree t = (tree)n->value;
-           var_ann_t va = var_ann (t);
-           if (va) 
-             bitmap_set_bit(in_ann, va->uid);
-         }
-      });
+  bitmap_iterator bi;
+
+  EXECUTE_IF_SET_IN_BITMAP(in_decl, 0, index, bi)
+    {
+      splay_tree_node n = 
+             splay_tree_lookup (static_vars_to_consider_by_uid, index);
+      if (n != NULL) 
+       {
+         tree t = (tree)n->value;
+         var_ann_t va = var_ann (t);
+         if (va) 
+           bitmap_set_bit(in_ann, va->uid);
+       }
+    }
 }
 
 /* FIXME -- PROFILE-RESTRUCTURE: Delete all stmts initing *_decl_uid
@@ -586,6 +589,9 @@ cgraph_finalize_function (tree decl, bool nested)
   notice_global_symbol (decl);
   node->decl = decl;
   node->local.finalized = true;
+  if (node->nested)
+    lower_nested_functions (decl);
+  gcc_assert (!node->nested);
 
   /* If not unit at a time, then we need to create the call graph
      now, so that called functions can be queued and emitted now.  */
@@ -671,7 +677,7 @@ record_call_1 (tree *tp, int *walk_subtrees, void *data)
     default:
       /* Save some cycles by not walking types and declaration as we
         won't find anything useful there anyway.  */
-      if (DECL_P (*tp) || TYPE_P (*tp))
+      if (IS_TYPE_OR_DECL_P (*tp))
        {
          *walk_subtrees = 0;
          break;
@@ -740,7 +746,7 @@ verify_cgraph_node_1 (tree *tp, int *walk_subtrees, void *data)
 
   /* Save some cycles by not walking types and declaration as we
      won't find anything useful there anyway.  */
-  if (DECL_P (*tp) || TYPE_P (*tp))
+  if (IS_TYPE_OR_DECL_P (*tp))
     *walk_subtrees = 0;
 
   return NULL_TREE;
@@ -2024,7 +2030,7 @@ bool has_proper_scope_for_analysis (tree t)
 }
 
 /* Check to see if T is a read or address of operation on a static var
-   we are interrested in analyzing.  FN is passed in to get access to
+   we are interested in analyzing.  FN is passed in to get access to
    its bit vectors.  */
 
 static void
@@ -2058,7 +2064,7 @@ check_rhs_var (struct cgraph_node *fn, tree t)
     }
 }
 
-/* Check to see if T is an assignement to a static var we are
+/* Check to see if T is an assignment to a static var we are
    interrested in analyzing.  FN is passed in to get access to its bit
    vectors.
 */
@@ -2225,18 +2231,18 @@ scan_for_static_refs (tree *tp,
        check_lhs_var (fn, TREE_OPERAND (t, 0));
        /* Next check the operands on the rhs to see if they are ok. */
        switch (TREE_CODE_CLASS (TREE_CODE (rhs))) {
-       case '2':
+       case tcc_binary:
          check_rhs_var (fn, TREE_OPERAND (rhs, 0));
          check_rhs_var (fn, TREE_OPERAND (rhs, 1));
          break;
-       case '1':
-       case 'r':
+       case tcc_unary:
+       case tcc_reference:
          check_rhs_var (fn, TREE_OPERAND (rhs, 0));
          break;
-       case 'd':
+       case tcc_declaration:
          check_rhs_var (fn, rhs);
          break;
-       case 'e':
+       case tcc_expression:
          switch (TREE_CODE (rhs)) {
          case ADDR_EXPR:
            check_rhs_var (fn, rhs);
@@ -2325,7 +2331,7 @@ clear_static_vars_maps (int index)
 /* FIXME -- PROFILE-RESTRUCTURE: Change all *_decl_uid to *_ann_uid.  */
 
 /* Or in all of the bits from every callee into X, the caller's, bit
-   vector.  There are several cases to check to avoid the sparce
+   vector.  There are several cases to check to avoid the sparse
    bitmap oring.  */
 static void
 cgraph_propagate_bits (struct cgraph_node *x)
@@ -2452,8 +2458,12 @@ cgraph_characterize_statics (void)
      (i.e. have there address taken).  */
   {
     int index;
-    EXECUTE_IF_SET_IN_BITMAP (module_statics_escape,
-                             0, index, clear_static_vars_maps (index));
+    bitmap_iterator bi;
+
+    EXECUTE_IF_SET_IN_BITMAP (module_statics_escape, 0, index, bi)
+      {
+       clear_static_vars_maps (index);
+      }
     bitmap_operation (all_module_statics, all_module_statics,
                      module_statics_escape, BITMAP_AND_COMPL);
 
@@ -2480,6 +2490,8 @@ cgraph_characterize_statics (void)
        {
          int index;
          local_static_vars_info_t l;
+         bitmap_iterator bi;
+
          node = order[i];
          l = node->static_vars_info->local;
          fprintf (cgraph_dump_file, 
@@ -2487,14 +2499,18 @@ cgraph_characterize_statics (void)
                   cgraph_node_name (node), node->uid);
          fprintf (cgraph_dump_file, "\n  locals read: ");
          EXECUTE_IF_SET_IN_BITMAP (l->statics_read_by_decl_uid,
-                                   0, index,
-                                   fprintf (cgraph_dump_file, "%s ",
-                                            cgraph_get_static_name_by_uid (index)));
+                                   0, index, bi)
+           {
+             fprintf (cgraph_dump_file, "%s ",
+                      cgraph_get_static_name_by_uid (index));
+           }
          fprintf (cgraph_dump_file, "\n  locals written: ");
          EXECUTE_IF_SET_IN_BITMAP (l->statics_written_by_decl_uid,
-                                   0, index,
-                                   fprintf(cgraph_dump_file, "%s ",
-                                          cgraph_get_static_name_by_uid (index)));
+                                   0, index, bi)
+           {
+             fprintf(cgraph_dump_file, "%s ",
+                     cgraph_get_static_name_by_uid (index));
+           }
        }
     }
 
@@ -2593,6 +2609,8 @@ cgraph_characterize_statics (void)
          static_vars_info_t node_info;
          global_static_vars_info_t node_g;
          int index;
+         bitmap_iterator bi;
+
          node = order[i];
          node_info = node->static_vars_info;
          node_g = node_info->global;
@@ -2608,14 +2626,18 @@ cgraph_characterize_statics (void)
            }
          fprintf (cgraph_dump_file, "\n  globals read: ");
          EXECUTE_IF_SET_IN_BITMAP (node_g->statics_read_by_decl_uid,
-                                   0, index,
-                                   fprintf (cgraph_dump_file, "%s ",
-                                            cgraph_get_static_name_by_uid (index)));
+                                   0, index, bi)
+           {
+             fprintf (cgraph_dump_file, "%s ",
+                      cgraph_get_static_name_by_uid (index));
+           }
          fprintf (cgraph_dump_file, "\n  globals written: ");
          EXECUTE_IF_SET_IN_BITMAP (node_g->statics_written_by_decl_uid,
-                                   0, index,
-                                   fprintf (cgraph_dump_file, "%s ",
-                                            cgraph_get_static_name_by_uid (index)));
+                                   0, index, bi)
+           {
+             fprintf (cgraph_dump_file, "%s ",
+                      cgraph_get_static_name_by_uid (index));
+           }
        }
     }
 
@@ -2901,7 +2923,7 @@ cgraph_build_static_cdtor (char which, tree body, int priority)
 
   /* ??? We will get called LATE in the compilation process.  */
   if (cgraph_global_info_ready)
-    tree_rest_of_compilation (decl, false);
+    tree_rest_of_compilation (decl);
   else
     cgraph_finalize_function (decl, 0);