[llvm-bugs] [Bug 48162] New: llvm-cov gcov does not add "(throw)" to branch statements

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 12 08:58:07 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48162

            Bug ID: 48162
           Summary: llvm-cov gcov does not add "(throw)" to branch
                    statements
           Product: Runtime Libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: libprofile library
          Assignee: unassignedbugs at nondot.org
          Reporter: John.Forrest at gbgplc.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 24158
  --> https://bugs.llvm.org/attachment.cgi?id=24158&action=edit
Sample files

I am using clang++ to generate coverage reports as part of Sonarqube analysis.
This expects the output from gcovr and we use the latter telling it to use
"llvm-cov gcov" as documented. We've hit the common(?) problem where the
reported coverage figures are low, due it seems to extra branches being added
for exception support. The recommended approach is to add flags
--exclude-throw-branches --exclude-unreachable-branches to gcovr. This has been
observed to help a little but not much.

Experimentation suggests that this relates to the llvm toolchain. gcov itself
(obviously what gcovr expects) adds extra tags to the branch statements with
"(throw)" and "(fallthrough)". It is these tags that gcovr uses to support
--exclude-throw=branches. llvm-cov does not, so gcovr assumes they are "normal"
branches - it has no option. E.g. compare (gcc/gcov):

branch  1 taken 1 (fallthrough)
branch  2 taken 0 (throw)

with (clang/llvm-cov gcov):

branch  0 taken 1
branch  1 taken 0

The attached zip contains a sample program and the respective output of
compiling (with "-O0 -g --coverage"), running and then extracting coverage with
flags "--branch-counts --branch-probabilities --preserve-paths". gcc is v8.3.1.
llvm is 11.0.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201112/ed607290/attachment-0001.html>


More information about the llvm-bugs mailing list