+ struct cgraph_node *node;
+
+ /* This is a small-ipa pass that gets called only once, from
+ cgraphunit.c:ipa_passes(). */
+ gcc_assert (cgraph_state == CGRAPH_STATE_IPA_SSA);
+
+ init_node_map();
+
+ FOR_EACH_DEFINED_FUNCTION (node)
+ {
+ if (!gimple_has_body_p (node->symbol.decl))
+ continue;
+
+ /* Don't profile functions produced for builtin stuff. */
+ if (DECL_SOURCE_LOCATION (node->symbol.decl) == BUILTINS_LOCATION)
+ continue;
+
+ push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
+
+ /* 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);
+ pop_cfun ();
+ }
+
+ /* Drop pure/const flags from instrumented functions. */
+ FOR_EACH_DEFINED_FUNCTION (node)
+ {
+ if (!gimple_has_body_p (node->symbol.decl)
+ || !(!node->clone_of
+ || node->symbol.decl != node->clone_of->symbol.decl))
+ continue;
+
+ /* Don't profile functions produced for builtin stuff. */
+ if (DECL_SOURCE_LOCATION (node->symbol.decl) == BUILTINS_LOCATION)
+ continue;
+
+ cgraph_set_const_flag (node, false, false);
+ cgraph_set_pure_flag (node, false, false);
+ }
+
+ /* Update call statements and rebuild the cgraph. */
+ FOR_EACH_DEFINED_FUNCTION (node)