[gcov] Fix wrong line hit counts when multiple blocks are on the same line
authorCalixte Denizet <cdenizet@mozilla.com>
Thu, 20 Sep 2018 16:09:30 +0000 (16:09 +0000)
committerCalixte Denizet <cdenizet@mozilla.com>
Thu, 20 Sep 2018 16:09:30 +0000 (16:09 +0000)
commit0b1fe47e22e69f9507ee57aece722969f2e7e695
treea2bf10f618f86039e1378d5766535d9221de6113
parentcfa1d499f92d52c2ac2443c52fb77ad2fc64591d
[gcov] Fix wrong line hit counts when multiple blocks are on the same line

Summary:
The goal of this patch is to have the same behaviour than gcc-gcov.
Currently the hit counts for a line is the sum of the counts for each block on that line.
The idea is to detect the cycles in the graph of blocks in using the algorithm by Hawick & James.
The count for a cycle is the min of the counts for each edge in the cycle.
Once we've the count for each cycle, we can sum them and add the transition counts of those cycles.

Fix both https://bugs.llvm.org/show_bug.cgi?id=38065 and https://bugs.llvm.org/show_bug.cgi?id=38066

Reviewers: marco-c, davidxl

Reviewed By: marco-c

Subscribers: vsk, lebedev.ri, sylvestre.ledru, dblaikie, llvm-commits

Differential Revision: https://reviews.llvm.org/D49659

llvm-svn: 342657
15 files changed:
llvm/include/llvm/ProfileData/GCOV.h
llvm/lib/ProfileData/GCOV.cpp
llvm/test/tools/llvm-cov/Inputs/test_-a.cpp.gcov
llvm/test/tools/llvm-cov/Inputs/test_-a.h.gcov
llvm/test/tools/llvm-cov/Inputs/test_-a_-b.cpp.gcov
llvm/test/tools/llvm-cov/Inputs/test_-a_-b.h.gcov
llvm/test/tools/llvm-cov/Inputs/test_-a_-b_-c_-u.cpp.gcov
llvm/test/tools/llvm-cov/Inputs/test_-a_-b_-c_-u.h.gcov
llvm/test/tools/llvm-cov/Inputs/test_-a_-b_-u.cpp.gcov
llvm/test/tools/llvm-cov/Inputs/test_-a_-b_-u.h.gcov
llvm/test/tools/llvm-cov/Inputs/test_missing.cpp.gcov
llvm/test/tools/llvm-cov/Inputs/test_no_options.cpp.gcov
llvm/test/tools/llvm-cov/Inputs/test_objdir.cpp.gcov
llvm/test/tools/llvm-cov/Inputs/test_paths.cpp.gcov
llvm/test/tools/llvm-cov/range_based_for.cpp