Patch tree-profile.c to support profile-func-internal-id parameter
Matt Deeds
mattdeeds@google.com
Thu Aug 27 15:25:00 GMT 2015
This patch is for svn://gcc.gnu.org/svn/gcc/branches/google/gcc-4_9. I add
support for the profile_func_internal-id in the instrumentation generated for
__coverage_callback.
Add support for the profile-func-internal-id parameter to the coverage callback.
Without this change, the function identifier passed to __coverage_callback
(enabled with param=coverage-callback=1) does not match the values emitted in
the .gcno file. Because the function profile_id is typically more unique
(typically 32 bits) than the function internal id (typically 16 bits), it can be
desirable to have the profile_id used to identify a function as opposed to the
function internal id.
I've instrumented a large binary creating over 500 .gcno files and confirmed
that function IDs in these .gcno files match the IDs in __coverage_callback. In
my example, there were typically about one to four functions sharing the same
internal function ID. There were no collisions using profile_id.
Index: gcc/tree-profile.c
===================================================================
--- gcc/tree-profile.c (revision 226647)
+++ gcc/tree-profile.c (working copy)
@@ -864,8 +864,20 @@ gimple_gen_edge_profiler (int edgeno, edge e)
{
gimple call;
tree tree_edgeno = build_int_cst (gcov_type_node, edgeno);
- tree tree_uid = build_int_cst (gcov_type_node,
+
+ tree tree_uid;
+ if (PARAM_VALUE (PARAM_PROFILE_FUNC_INTERNAL_ID))
+ {
+ tree_uid = build_int_cst (gcov_type_node,
current_function_funcdef_no);
+ }
+ else
+ {
+ gcc_assert (coverage_node_map_initialized_p ());
+
+ tree_uid = build_int_cst
+ (gcov_type_node, cgraph_get_node (current_function_decl)->profile_id);
+ }
tree callback_fn_type
= build_function_type_list (void_type_node,
gcov_type_node,
More information about the Gcc-patches
mailing list