Commit 2e9ff3bb by Martin Liska Committed by Martin Liska

Do not follow zero edges in cycle detection (PR gcov-profile/90380).

2019-05-13  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/90380
	* gcov.c (handle_cycle): Do not support zero cycle count,
	it should not be possible.
	(path_contains_zero_cycle_arc): New function.
	(circuit): Ignore zero cycle arc counts.

From-SVN: r271117
parent 4af3b0ea
2019-05-13 Martin Liska <mliska@suse.cz> 2019-05-13 Martin Liska <mliska@suse.cz>
PR gcov-profile/90380 PR gcov-profile/90380
* gcov.c (handle_cycle): Do not support zero cycle count,
it should not be possible.
(path_contains_zero_cycle_arc): New function.
(circuit): Ignore zero cycle arc counts.
2019-05-13 Martin Liska <mliska@suse.cz>
PR gcov-profile/90380
* gcov.c (enum loop_type): Remove the enum and * gcov.c (enum loop_type): Remove the enum and
the operator. the operator.
(handle_cycle): Assert that we should not reach (handle_cycle): Assert that we should not reach
......
...@@ -696,7 +696,7 @@ handle_cycle (const arc_vector_t &edges, int64_t &count) ...@@ -696,7 +696,7 @@ handle_cycle (const arc_vector_t &edges, int64_t &count)
for (unsigned i = 0; i < edges.size (); i++) for (unsigned i = 0; i < edges.size (); i++)
edges[i]->cs_count -= cycle_count; edges[i]->cs_count -= cycle_count;
gcc_assert (cycle_count >= 0); gcc_assert (cycle_count > 0);
} }
/* Unblock a block U from BLOCKED. Apart from that, iterate all blocks /* Unblock a block U from BLOCKED. Apart from that, iterate all blocks
...@@ -722,6 +722,17 @@ unblock (const block_info *u, block_vector_t &blocked, ...@@ -722,6 +722,17 @@ unblock (const block_info *u, block_vector_t &blocked,
unblock (*it, blocked, block_lists); unblock (*it, blocked, block_lists);
} }
/* Return true when PATH contains a zero cycle arc count. */
static bool
path_contains_zero_cycle_arc (arc_vector_t &path)
{
for (unsigned i = 0; i < path.size (); i++)
if (path[i]->cs_count == 0)
return true;
return false;
}
/* Find circuit going to block V, PATH is provisional seen cycle. /* Find circuit going to block V, PATH is provisional seen cycle.
BLOCKED is vector of blocked vertices, BLOCK_LISTS contains vertices BLOCKED is vector of blocked vertices, BLOCK_LISTS contains vertices
blocked by a block. COUNT is accumulated count of the current LINE. blocked by a block. COUNT is accumulated count of the current LINE.
...@@ -742,7 +753,9 @@ circuit (block_info *v, arc_vector_t &path, block_info *start, ...@@ -742,7 +753,9 @@ circuit (block_info *v, arc_vector_t &path, block_info *start,
for (arc_info *arc = v->succ; arc; arc = arc->succ_next) for (arc_info *arc = v->succ; arc; arc = arc->succ_next)
{ {
block_info *w = arc->dst; block_info *w = arc->dst;
if (w < start || !linfo.has_block (w)) if (w < start
|| arc->cs_count == 0
|| !linfo.has_block (w))
continue; continue;
path.push_back (arc); path.push_back (arc);
...@@ -752,7 +765,8 @@ circuit (block_info *v, arc_vector_t &path, block_info *start, ...@@ -752,7 +765,8 @@ circuit (block_info *v, arc_vector_t &path, block_info *start,
handle_cycle (path, count); handle_cycle (path, count);
loop_found = true; loop_found = true;
} }
else if (find (blocked.begin (), blocked.end (), w) == blocked.end ()) else if (!path_contains_zero_cycle_arc (path)
&& find (blocked.begin (), blocked.end (), w) == blocked.end ())
loop_found |= circuit (w, path, start, blocked, block_lists, linfo, loop_found |= circuit (w, path, start, blocked, block_lists, linfo,
count); count);
...@@ -765,7 +779,9 @@ circuit (block_info *v, arc_vector_t &path, block_info *start, ...@@ -765,7 +779,9 @@ circuit (block_info *v, arc_vector_t &path, block_info *start,
for (arc_info *arc = v->succ; arc; arc = arc->succ_next) for (arc_info *arc = v->succ; arc; arc = arc->succ_next)
{ {
block_info *w = arc->dst; block_info *w = arc->dst;
if (w < start || !linfo.has_block (w)) if (w < start
|| arc->cs_count == 0
|| !linfo.has_block (w))
continue; continue;
size_t index size_t index
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment