+ for (node = cgraph_nodes; node; node = node->next)
+ {
+ if (!node->analyzed
+ || !gimple_has_body_p (node->decl))
+ continue;
+
+ /* Don't profile functions produced for builtin stuff. */
+ if (DECL_SOURCE_LOCATION (node->decl) == BUILTINS_LOCATION
+ || DECL_STRUCT_FUNCTION (node->decl)->after_tree_profile)
+ continue;
+
+ push_cfun (DECL_STRUCT_FUNCTION (node->decl));
+ current_function_decl = node->decl;
+
+ /* Re-set global shared temporary variable for edge-counters. */
+ gcov_type_tmp_var = NULL_TREE;
+
+ /* Local pure-const may imply need to fixup the cfg. */
+ if (execute_fixup_cfg () & TODO_cleanup_cfg)
+ cleanup_tree_cfg ();
+ branch_prob ();
+
+ if (! flag_branch_probabilities
+ && flag_profile_values)
+ gimple_gen_ic_func_profiler ();
+
+ if (flag_branch_probabilities
+ && flag_profile_values
+ && flag_value_profile_transformations)
+ gimple_value_profile_transformations ();
+
+ /* The above could hose dominator info. Currently there is
+ none coming in, this is a safety valve. It should be
+ easy to adjust it, if and when there is some. */
+ free_dominance_info (CDI_DOMINATORS);
+ free_dominance_info (CDI_POST_DOMINATORS);
+
+ current_function_decl = NULL;
+ pop_cfun ();
+ }
+
+ /* Drop pure/const flags from instrumented functions. */
+ for (node = cgraph_nodes; node; node = node->next)
+ {
+ if (!node->analyzed
+ || !gimple_has_body_p (node->decl)
+ || !(!node->clone_of || node->decl != node->clone_of->decl))
+ continue;
+
+ /* Don't profile functions produced for builtin stuff. */
+ if (DECL_SOURCE_LOCATION (node->decl) == BUILTINS_LOCATION
+ || DECL_STRUCT_FUNCTION (node->decl)->after_tree_profile)
+ continue;
+
+ cgraph_set_const_flag (node, false, false);
+ cgraph_set_pure_flag (node, false, false);
+ }
+
+ /* Update call statements and rebuild the cgraph. */
+ for (node = cgraph_nodes; node; node = node->next)
+ {
+ basic_block bb;
+
+ if (!node->analyzed
+ || !gimple_has_body_p (node->decl)
+ || !(!node->clone_of || node->decl != node->clone_of->decl))
+ continue;
+
+ /* Don't profile functions produced for builtin stuff. */
+ if (DECL_SOURCE_LOCATION (node->decl) == BUILTINS_LOCATION
+ || DECL_STRUCT_FUNCTION (node->decl)->after_tree_profile)
+ continue;
+
+ push_cfun (DECL_STRUCT_FUNCTION (node->decl));
+ current_function_decl = node->decl;
+
+ FOR_EACH_BB (bb)
+ {
+ gimple_stmt_iterator gsi;
+ for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+ {
+ gimple stmt = gsi_stmt (gsi);
+ if (is_gimple_call (stmt))
+ update_stmt (stmt);
+ }
+ }
+
+ cfun->after_tree_profile = 1;
+ update_ssa (TODO_update_ssa);
+
+ rebuild_cgraph_edges ();
+
+ current_function_decl = NULL;
+ pop_cfun ();
+ }
+
+ del_node_map();
+ return 0;