aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-profile.c
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2019-01-01 13:49:18 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2019-01-01 12:49:18 +0000
commit962e88a9f5a19736412f8b17b24464e2b700f002 (patch)
tree1f3f47a623168992283688de2d7a2a6b07341b11 /gcc/tree-profile.c
parenta5544970246db337977bb8b69ab120e9ef209317 (diff)
downloadgcc-962e88a9f5a19736412f8b17b24464e2b700f002.zip
gcc-962e88a9f5a19736412f8b17b24464e2b700f002.tar.gz
gcc-962e88a9f5a19736412f8b17b24464e2b700f002.tar.bz2
coverage.c (get_coverage_counts): Use current_function_decl.
* coverage.c (get_coverage_counts): Use current_function_decl. * profile.c (read_thunk_profile): New function. (branch_prob): Add THUNK parameter. * tree-profile.c (tree_profiling): Handle thunks. * value-prof.c (init_node_map): Handle thunks. * value-prof.h (branch_prob): Upate prototype. (read_thunk_profile): Declare. * g++.dg/tree-prof/devirt.C: Update testcase. From-SVN: r267495
Diffstat (limited to 'gcc/tree-profile.c')
-rw-r--r--gcc/tree-profile.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index ab4a439..30fadde 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -739,7 +739,8 @@ tree_profiling (void)
FOR_EACH_DEFINED_FUNCTION (node)
{
- if (!gimple_has_body_p (node->decl))
+ bool thunk = false;
+ if (!gimple_has_body_p (node->decl) && !node->thunk.thunk_p)
continue;
/* Don't profile functions produced for builtin stuff. */
@@ -760,22 +761,43 @@ tree_profiling (void)
if (!include_source_file_for_profile (file))
continue;
+ if (node->thunk.thunk_p)
+ {
+ /* We can not expand variadic thunks to Gimple. */
+ if (stdarg_p (TREE_TYPE (node->decl)))
+ continue;
+ thunk = true;
+ /* When generate profile, expand thunk to gimple so it can be
+ instrumented same way as other functions. */
+ if (profile_arc_flag)
+ node->expand_thunk (false, true);
+ /* Read cgraph profile but keep function as thunk at profile-use
+ time. */
+ else
+ {
+ read_thunk_profile (node);
+ continue;
+ }
+ }
+
push_cfun (DECL_STRUCT_FUNCTION (node->decl));
if (dump_file)
dump_function_header (dump_file, cfun->decl, dump_flags);
/* Local pure-const may imply need to fixup the cfg. */
- if (execute_fixup_cfg () & TODO_cleanup_cfg)
+ if (gimple_has_body_p (node->decl)
+ && (execute_fixup_cfg () & TODO_cleanup_cfg))
cleanup_tree_cfg ();
- branch_prob ();
+ branch_prob (thunk);
if (! flag_branch_probabilities
&& flag_profile_values)
gimple_gen_ic_func_profiler ();
if (flag_branch_probabilities
+ && !thunk
&& flag_profile_values
&& flag_value_profile_transformations)
gimple_value_profile_transformations ();