OSDN Git Service

PR c++/17868
[pf3gnuchains/gcc-fork.git] / gcc / cgraphunit.c
index 4153504..5d0a32f 100644 (file)
@@ -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;
@@ -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);
@@ -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);