[llvm-bugs] [Bug 41821] New: [LLVM-COV] A "break; " statement is wrongly marked as executed when it is after the "abort(); " statement in switch-case

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 9 10:43:00 PDT 2019


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

            Bug ID: 41821
           Summary: [LLVM-COV] A "break;" statement is wrongly marked as
                    executed when it is after the "abort();" statement in
                    switch-case
           Product: Runtime Libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: libprofile library
          Assignee: unassignedbugs at nondot.org
          Reporter: yangyibiao at nju.edu.cn
                CC: llvm-bugs at lists.llvm.org

$ clang -v
clang version 9.0.0-svn358899-1~exp1+0~20190422164136.937~1.gbpac4d8e (trunk)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64


$ rm a.out small.lcov small.p*; clang -w -O0 -g -fcoverage-mapping
-fprofile-instr-generate=small.profraw small.c; ./a.out; llvm-profdata merge
small.profraw -o small.profdata; llvm-cov show a.out
-instr-profile=small.profdata small.c > small.lcov; cat small.lcov
    1|       |int main()
    2|      1|{
    3|      1|  switch (8)
    4|      1|  {
    5|      1|    case 8:
    6|      1|      break;
    7|      1|    default:
    8|      0|      abort ();
    9|      1|      break;
   10|      1|  }
   11|      1|  return 0;
   12|      1|}

Line #9 is wrongly marked as executed. In fact, it is obvious that Line #9 is
not executed. 

When Line #8 is removed, the coverage is correct as follows:

$ rm a.out small.lcov small.p*; clang -w -O0 -g -fcoverage-mapping
-fprofile-instr-generate=small.profraw small.c; ./a.out; llvm-profdata merge
small.profraw -o small.profdata; llvm-cov show a.out
-instr-profile=small.profdata small.c > small.lcov; cat small.lcov
    1|       |int main()
    2|      1|{
    3|      1|  switch (8)
    4|      1|  {
    5|      1|    case 8:
    6|      1|      break;
    7|      1|    default:
    8|      0|      // abort ();
    9|      0|      break;
   10|      1|  }
   11|      1|  return 0;
   12|      1|}

-- 
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/20190509/8eb7fb3f/attachment.html>


More information about the llvm-bugs mailing list