summaryrefslogtreecommitdiff
path: root/gcc/profile.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2018-07-31 12:33:21 +0200
committerMartin Liska <marxin@gcc.gnu.org>2018-07-31 10:33:21 +0000
commit102fcf94e625a2016a65829c73a42bd6c2420376 (patch)
treeadbc04540f28f40a8827907f4f6b9b8e4883323a /gcc/profile.c
parent5dbc3940fcd15ff477eb556630734017dd2b0cff (diff)
Fix GCOV CFG related issues.
2018-07-31 Martin Liska <mliska@suse.cz> PR gcov-profile/83813 PR gcov-profile/84758 PR gcov-profile/85217 PR gcov-profile/85332 * profile.c (branch_prob): Do not record GOTO expressions for GIMPLE statements which locations are already streamed. 2018-07-31 Martin Liska <mliska@suse.cz> PR gcov-profile/83813 PR gcov-profile/84758 PR gcov-profile/85217 PR gcov-profile/85332 * gcc.misc-tests/gcov-pr83813.c: New test. * gcc.misc-tests/gcov-pr84758.c: New test. * gcc.misc-tests/gcov-pr85217.c: New test. * gcc.misc-tests/gcov-pr85332.c: New test. From-SVN: r263111
Diffstat (limited to 'gcc/profile.c')
-rw-r--r--gcc/profile.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/gcc/profile.c b/gcc/profile.c
index 0cd0270b4fb..00f37b657a4 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -1256,6 +1256,8 @@ branch_prob (void)
/* Initialize the output. */
output_location (NULL, 0, NULL, NULL);
+ hash_set<int_hash <location_t, 0, 2> > seen_locations;
+
FOR_EACH_BB_FN (bb, cfun)
{
gimple_stmt_iterator gsi;
@@ -1263,8 +1265,9 @@ branch_prob (void)
if (bb == ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb)
{
- expanded_location curr_location =
- expand_location (DECL_SOURCE_LOCATION (current_function_decl));
+ location_t loc = DECL_SOURCE_LOCATION (current_function_decl);
+ seen_locations.add (loc);
+ expanded_location curr_location = expand_location (loc);
output_location (curr_location.file, curr_location.line,
&offset, bb);
}
@@ -1272,17 +1275,25 @@ branch_prob (void)
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
gimple *stmt = gsi_stmt (gsi);
- if (!RESERVED_LOCATION_P (gimple_location (stmt)))
- output_location (gimple_filename (stmt), gimple_lineno (stmt),
- &offset, bb);
+ location_t loc = gimple_location (stmt);
+ if (!RESERVED_LOCATION_P (loc))
+ {
+ seen_locations.add (loc);
+ output_location (gimple_filename (stmt), gimple_lineno (stmt),
+ &offset, bb);
+ }
}
- /* Notice GOTO expressions eliminated while constructing the CFG. */
+ /* Notice GOTO expressions eliminated while constructing the CFG.
+ It's hard to distinguish such expression, but goto_locus should
+ not be any of already seen location. */
+ location_t loc;
if (single_succ_p (bb)
- && !RESERVED_LOCATION_P (single_succ_edge (bb)->goto_locus))
+ && (loc = single_succ_edge (bb)->goto_locus)
+ && !RESERVED_LOCATION_P (loc)
+ && !seen_locations.contains (loc))
{
- expanded_location curr_location
- = expand_location (single_succ_edge (bb)->goto_locus);
+ expanded_location curr_location = expand_location (loc);
output_location (curr_location.file, curr_location.line,
&offset, bb);
}