[llvm-bugs] [Bug 45595] New: wrong coverage for the function alloca() call statement

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Apr 18 02:14:48 PDT 2020


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

            Bug ID: 45595
           Summary: wrong coverage for the function alloca() call
                    statement
           Product: Runtime Libraries
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: libprofile library
          Assignee: unassignedbugs at nondot.org
          Reporter: yangyibiao at hust.edu.cn
                CC: llvm-bugs at lists.llvm.org

$ clang -v
clang version 9.0.1 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/9.3.0
Found candidate GCC installation:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/9.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/9.3.0
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/9.3.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64


$ cat small.c
#include <setjmp.h>
#include <stdlib.h>

jmp_buf buf;

void sub (void)
{
  longjmp (buf, 1);
}

int main ()
{
  if (setjmp (buf)) {
    exit (0);
  }

  int *q = (int *) alloca (10 * sizeof (int));

  for (int i = 0; i < 10; i++)
    q[i] = 0;

  while (1)
    sub ();
}


$ clang -O0 -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
    1|       |#include <setjmp.h>
    2|       |#include <stdlib.h>
    3|       |
    4|       |jmp_buf buf;
    5|       |
    6|       |void sub (void)
    7|      1|{
    8|      1|  longjmp (buf, 1);
    9|      1|}
   10|       |
   11|       |int main ()
   12|      1|{
   13|      1|  if (setjmp (buf)) {
   14|      1|    exit (0);
   15|      1|  }
   16|      0|
   17|      0|  int *q = (int *) alloca (10 * sizeof (int));
   18|      0|
   19|     10|  for (int i = 0; i < 10; i++)
   20|     10|    q[i] = 0;
   21|      0|
   22|      1|  while (1)
   23|      1|    sub ();
   24|      0|}

*****
Line #17 is wrongly marked as not executed. The correct coverage should be
"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/20200418/af7cafab/attachment.html>


More information about the llvm-bugs mailing list