[llvm-bugs] [Bug 48830] New: llvm-cov: wrong coverage for setjmp followed by a while loop statement

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 20 22:12:03 PST 2021


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

            Bug ID: 48830
           Summary: llvm-cov: wrong coverage for setjmp followed by a
                    while loop statement
           Product: Runtime Libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: libprofile library
          Assignee: unassignedbugs at nondot.org
          Reporter: yangyibiao at nju.edu.cn
                CC: llvm-bugs at lists.llvm.org

...
Consider this case:
$ cat small.c
void *buf[20];

void foo()
{
  __builtin_longjmp (buf, 1);
}

int main ()
{
  if(__builtin_setjmp(buf))
    return 1;

  printf("Hello, world!\n");
  while(1)
    foo();
}
...

$ clang -O0 -w -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.c.lcov; cat
small.c.lcov
Hello, world!
    1|       |void *buf[20];
    2|       |
    3|       |void foo()
    4|      1|{
    5|      1|  __builtin_longjmp (buf, 1);
    6|      1|}
    7|       |
    8|       |int main ()
    9|      1|{
   10|      1|  if(__builtin_setjmp(buf))
   11|      1|    return 1;
   12|       |
   13|      0|  printf("Hello, world!\n");
   14|      1|  while(1)
   15|      1|    foo();
   16|      0|}
...

We can found that Line #13 is wrongly marked as not executed. However, "Hello,
world!"is printed. This indicates that Line #13 is executed. 

$ clang --version
Ubuntu clang version
12.0.0-++20210120052627+c09be0d2a0f9-1~exp1~20210120163331.290
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

-- 
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/20210121/6321563d/attachment.html>


More information about the llvm-bugs mailing list