[llvm-bugs] [Bug 51009] New: [llvm-cov] "__builtin_setjump(buf)" statement leads to the incorrect coverage of the next statement.
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jul 7 05:16:53 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51009
Bug ID: 51009
Summary: [llvm-cov] "__builtin_setjump(buf)" statement leads to
the incorrect coverage of the next statement.
Product: Runtime Libraries
Version: 12.0
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: libprofile library
Assignee: unassignedbugs at nondot.org
Reporter: byone.heng at gmail.com
CC: llvm-bugs at lists.llvm.org
$./clang -v
clang version 12.0.0 (https://github.com/llvm/llvm-project.git
b6c8feb29fce39121884f7e08ec6eb0f58da3fb7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/x/project/llvm-project/build/install/bin/.
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$cat test.c
———————————————————
#include <setjmp.h>
short int true_var = 1;
const volatile unsigned short int false_var = 0;
extern void abort (void);
jmp_buf buf;
void raise0(void)
{
__builtin_longjmp (buf, 1);
}
int execute(int cmd)
{
int last = 0;
__builtin_setjmp (buf);
if( true_var > 0 )
{
if (last == 0)
while (1)
{
last = 1;
raise0 ();
}
}
if (last == 0)
return 0;
else
return cmd;
}
int main(void)
{
if (execute (1) == 0)
abort ();
return 0;
}
——————————————————
$clang -O0 -g -fcoverage-mapping -fprofile-instr-generate=test.profraw test.c;
./a.out; llvm-profdata merge test.profraw -o test.profdata; llvm-cov show a.out
-instr-profile=test.profdata test.c > test.lcov; cat test.lcov
5| |#include <setjmp.h>
6| |
7| |short int true_var = 1;
8| |const volatile unsigned short int false_var = 0;
9| |
10| |extern void abort (void);
11| |
12| |jmp_buf buf;
13| |
14| |void raise0(void)
15| 1|{
16| 1| __builtin_longjmp (buf, 1);
17| 1|}
18| |
19| |int execute(int cmd)
20| 1|{
21| 1| int last = 0;
22| |
23| 1| __builtin_setjmp (buf);
24| |
25| 1| if( true_var > 0 )
26| 2| {
27| 2| if (last == 0)
28| 2| while (1)
29| 1| {
30| 1| last = 1;
31| 1| raise0 ();
32| 1| }
33| 2| }
34| |
35| 1| if (last == 0)
36| 0| return 0;
37| 1| else
38| 1| return cmd;
39| 1|}
40| |
41| |int main(void)
42| 1|{
43| 1| if (execute (1) == 0)
44| 0| abort ();
45| |
46| 1| return 0;
47| 1|}
Line 25 should be executed twice.
--
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/20210707/9a724f76/attachment.html>
More information about the llvm-bugs
mailing list