-static unsigned int
-tree_profiling (void)
-{
- /* Don't profile functions produced at destruction time, particularly
- the gcov datastructure initializer. Don't profile if it has been
- already instrumented either (when OpenMP expansion creates
- child function from already instrumented body). */
- if (cgraph_state == CGRAPH_STATE_FINISHED
- || cfun->after_tree_profile)
- return 0;
-
- /* Re-set global shared temporary variable for edge-counters. */
- gcov_type_tmp_var = NULL_TREE;
-
- branch_prob ();
-
- if (! flag_branch_probabilities
- && flag_profile_values)
- tree_gen_ic_func_profiler ();
-
- if (flag_branch_probabilities
- && flag_profile_values
- && flag_value_profile_transformations)
- 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);
- cfun->after_tree_profile = 1;
+ /* Drop pure/const flags from instrumented functions. */
+ if (profile_arc_flag || flag_test_coverage)
+ FOR_EACH_DEFINED_FUNCTION (node)
+ {
+ if (!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)
+ continue;
+
+ node->set_const_flag (false, false);
+ node->set_pure_flag (false, false);
+ }
+
+ /* Update call statements and rebuild the cgraph. */
+ FOR_EACH_DEFINED_FUNCTION (node)
+ {
+ basic_block bb;
+
+ if (!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)
+ continue;
+
+ push_cfun (DECL_STRUCT_FUNCTION (node->decl));
+
+ FOR_EACH_BB_FN (bb, cfun)
+ {
+ 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);
+ }
+ }
+
+ /* re-merge split blocks. */
+ cleanup_tree_cfg ();
+ update_ssa (TODO_update_ssa);
+
+ cgraph_edge::rebuild_edges ();
+
+ pop_cfun ();
+ }
+
+ handle_missing_profiles ();
+
+ del_node_map ();