aboutsummaryrefslogtreecommitdiff
path: root/gcc/gcov.c
diff options
context:
space:
mode:
authorZdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>2003-08-27 23:13:17 +0200
committerZdenek Dvorak <rakdver@gcc.gnu.org>2003-08-27 21:13:17 +0000
commit3d7ca1673b3387bf420f02e3b45122ab75ff15e5 (patch)
tree7c28704c1941f5fa04436a77f72fd996d53ee36f /gcc/gcov.c
parent37e0ff11557b3ebc5917151becaaeb9514c8692d (diff)
downloadgcc-3d7ca1673b3387bf420f02e3b45122ab75ff15e5.zip
gcc-3d7ca1673b3387bf420f02e3b45122ab75ff15e5.tar.gz
gcc-3d7ca1673b3387bf420f02e3b45122ab75ff15e5.tar.bz2
gcov.c (typedef struct arc_info): New field cs_count.
* gcov.c (typedef struct arc_info): New field cs_count. (accumulate_line_counts): Find cycles correctly. * gcc.misc-tests/gcov-10b.c: New test. From-SVN: r70859
Diffstat (limited to 'gcc/gcov.c')
-rw-r--r--gcc/gcov.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 4c9af4d..d3037c7 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -82,6 +82,8 @@ typedef struct arc_info
/* transition counts. */
gcov_type count;
+ /* used in cycle search, so that we do not clobber original counts. */
+ gcov_type cs_count;
unsigned int count_valid : 1;
unsigned int on_tree : 1;
@@ -1622,6 +1624,10 @@ accumulate_line_counts (source_t *src)
if (flag_branches)
add_branch_counts (&src->coverage, arc);
}
+
+ /* Initialize the cs_count. */
+ for (arc = block->succ; arc; arc = arc->succ_next)
+ arc->cs_count = arc->count;
}
/* Find the loops. This uses the algorithm described in
@@ -1638,7 +1644,8 @@ accumulate_line_counts (source_t *src)
For each loop we find, locate the arc with the smallest
transition count, and add that to the cumulative
- count. Remove the arc from consideration. */
+ count. Decrease flow over the cycle and remove the arc
+ from consideration. */
for (block = line->u.blocks; block; block = block->chain)
{
block_t *head = block;
@@ -1664,25 +1671,33 @@ accumulate_line_counts (source_t *src)
if (dst == block)
{
/* Found a closing arc. */
- gcov_type cycle_count = arc->count;
+ gcov_type cycle_count = arc->cs_count;
arc_t *cycle_arc = arc;
arc_t *probe_arc;
/* Locate the smallest arc count of the loop. */
for (dst = head; (probe_arc = dst->u.cycle.arc);
dst = probe_arc->src)
- if (cycle_count > probe_arc->count)
+ if (cycle_count > probe_arc->cs_count)
{
- cycle_count = probe_arc->count;
+ cycle_count = probe_arc->cs_count;
cycle_arc = probe_arc;
}
count += cycle_count;
cycle_arc->cycle = 1;
+
+ /* Remove the flow from the cycle. */
+ arc->cs_count -= cycle_count;
+ for (dst = head; (probe_arc = dst->u.cycle.arc);
+ dst = probe_arc->src)
+ probe_arc->cs_count -= cycle_count;
+
/* Unwind to the cyclic arc. */
while (head != cycle_arc->src)
{
arc = head->u.cycle.arc;
+ head->u.cycle.arc = NULL;
head = arc->src;
}
/* Move on. */