[Bug gcov-profile/67937] New: gcov gives wrong results when negative counts are involved
Pidgeot18 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Oct 12 15:51:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67937
Bug ID: 67937
Summary: gcov gives wrong results when negative counts are
involved
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
Assignee: unassigned at gcc dot gnu.org
Reporter: Pidgeot18 at gmail dot com
Target Milestone: ---
This is hard to name correctly, since there's really a bigger bug here, and I'm
focusing on the lesser bug because it's easier for me to build a minimized test
case.
First the explanation: for whatever reason, sometimes gcov produces counts with
negative edges (that's a bug by itself). An minimized example of such a case
will be attached to the bug. In this scenario, the graph looks like this:
1147 +-+ -42
/----->|B|------\
+-+ +-+ +-+
/>|A| V 1189 |D| \
| +-+ +-+ +-+ |
| \----->|C|------/ |
\ 0 +-+ 1189 /
\-------------------/
23
(This is a result of an optimized loop, I don't have the corresponding code on
hand, sorry :-( ).
In this scenario, the loop detection code finds the following loops:
D -> A -> B -> C -> D: loop count = 23
D -> A -> B -> D: loop count = -42
D -> A -> C -> D: loop count = 0
A -> B -> C -> D -> A: loop count = 42
A -> B -> D -> A: loop count = 0
B -> C -> D -> A -> B: loop count = 0
C -> D -> A -> B -> C: loop count = 0
The last four loops are finding permutations of the three simple loops, which
is wrong (of course, the fact that one edge has a count of -42 in the first
place is wrong in the first place.
More information about the Gcc-bugs
mailing list