OSDN Git Service

* config/m32c/m32c-protos.h (m32c_function_arg): Delete.
[pf3gnuchains/gcc-fork.git] / gcc / cgraphbuild.c
index b09963d..3bd42e3 100644 (file)
@@ -275,7 +275,7 @@ mark_load (gimple stmt ATTRIBUTE_UNUSED, tree t,
           void *data ATTRIBUTE_UNUSED)
 {
   t = get_base_address (t);
-  if (TREE_CODE (t) == VAR_DECL
+  if (t && TREE_CODE (t) == VAR_DECL
       && (TREE_STATIC (t) || DECL_EXTERNAL (t)))
     {
       struct varpool_node *vnode = varpool_node (t);
@@ -300,7 +300,7 @@ mark_store (gimple stmt ATTRIBUTE_UNUSED, tree t,
            void *data ATTRIBUTE_UNUSED)
 {
   t = get_base_address (t);
-  if (TREE_CODE (t) == VAR_DECL
+  if (t && TREE_CODE (t) == VAR_DECL
       && (TREE_STATIC (t) || DECL_EXTERNAL (t)))
     {
       struct varpool_node *vnode = varpool_node (t);
@@ -328,7 +328,8 @@ build_cgraph_edges (void)
   struct cgraph_node *node = cgraph_node (current_function_decl);
   struct pointer_set_t *visited_nodes = pointer_set_create ();
   gimple_stmt_iterator gsi;
-  tree step;
+  tree decl;
+  unsigned ix;
 
   /* Create the callgraph edges and record the nodes referenced by the function.
      body.  */
@@ -339,12 +340,21 @@ build_cgraph_edges (void)
          gimple stmt = gsi_stmt (gsi);
          tree decl;
 
-         if (is_gimple_call (stmt) && (decl = gimple_call_fndecl (stmt)))
-           cgraph_create_edge (node, cgraph_node (decl), stmt,
-                               bb->count,
-                               compute_call_stmt_bb_frequency
-                                 (current_function_decl, bb),
-                               bb->loop_depth);
+         if (is_gimple_call (stmt))
+           {
+             int freq = compute_call_stmt_bb_frequency (current_function_decl,
+                                                        bb);
+             decl = gimple_call_fndecl (stmt);
+             if (decl)
+               cgraph_create_edge (node, cgraph_node (decl), stmt,
+                                   bb->count, freq,
+                                   bb->loop_depth);
+             else
+               cgraph_create_indirect_edge (node, stmt,
+                                            gimple_call_flags (stmt),
+                                            bb->count, freq,
+                                            bb->loop_depth);
+           }
          walk_stmt_load_store_addr_ops (stmt, node, mark_load,
                                         mark_store, mark_address);
          if (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
@@ -369,15 +379,10 @@ build_cgraph_edges (void)
    }
 
   /* Look for initializers of constant variables and private statics.  */
-  for (step = cfun->local_decls;
-       step;
-       step = TREE_CHAIN (step))
-    {
-      tree decl = TREE_VALUE (step);
-      if (TREE_CODE (decl) == VAR_DECL
-         && (TREE_STATIC (decl) && !DECL_EXTERNAL (decl)))
-       varpool_finalize_decl (decl);
-    }
+  FOR_EACH_LOCAL_DECL (cfun, ix, decl)
+    if (TREE_CODE (decl) == VAR_DECL
+       && (TREE_STATIC (decl) && !DECL_EXTERNAL (decl)))
+      varpool_finalize_decl (decl);
   record_eh_tables (node, cfun);
 
   pointer_set_destroy (visited_nodes);
@@ -443,12 +448,21 @@ rebuild_cgraph_edges (void)
          gimple stmt = gsi_stmt (gsi);
          tree decl;
 
-         if (is_gimple_call (stmt) && (decl = gimple_call_fndecl (stmt)))
-           cgraph_create_edge (node, cgraph_node (decl), stmt,
-                               bb->count,
-                               compute_call_stmt_bb_frequency
-                                 (current_function_decl, bb),
-                               bb->loop_depth);
+         if (is_gimple_call (stmt))
+           {
+             int freq = compute_call_stmt_bb_frequency (current_function_decl,
+                                                        bb);
+             decl = gimple_call_fndecl (stmt);
+             if (decl)
+               cgraph_create_edge (node, cgraph_node (decl), stmt,
+                                   bb->count, freq,
+                                   bb->loop_depth);
+             else
+               cgraph_create_indirect_edge (node, stmt,
+                                            gimple_call_flags (stmt),
+                                            bb->count, freq,
+                                            bb->loop_depth);
+           }
          walk_stmt_load_store_addr_ops (stmt, node, mark_load,
                                         mark_store, mark_address);