[llvm-bugs] [Bug 51011] New: [llvm-cov] wrong coverage for a for loop within "exit(0)" statement
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jul 7 06:30:30 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51011
Bug ID: 51011
Summary: [llvm-cov] wrong coverage for a for loop within
"exit(0)" 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
———————————————————
unsigned int true_var = 1;
static const unsigned int false_var = 0;
extern void exit (int);
extern void abort (void);
volatile int a = 1;
volatile int b = 0;
volatile int x = 2;
volatile signed int r = 8;
void __attribute__((noinline))
foo (void)
{
exit (0);
}
int
main (void)
{
int si1 = a;
int si2 = b;
int i;
for (i = 0; i < 100; ++i) {
foo ();
if (x == 8)
i++;
r += i + si1 % si2;
}
abort ();
}
——————————————————
$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
1| |
2| |unsigned int true_var = 1;
3| |static const unsigned int false_var = 0;
4| |extern void exit (int);
5| |extern void abort (void);
6| |
7| |volatile int a = 1;
8| |volatile int b = 0;
9| |volatile int x = 2;
10| |volatile signed int r = 8;
11| |
12| |void __attribute__((noinline))
13| |foo (void)
14| 1|{
15| 1| exit (0);
16| 1|}
17| |
18| |int
19| |main (void)
20| 1|{
21| 1| int si1 = a;
22| 1| int si2 = b;
23| 1| int i;
24| |
25| 2| for (i = 0; i < 100; ++i) {
26| 1| foo ();
27| 1| if (x == 8)
28| 0| i++;
29| 1| r += i + si1 % si2;
30| 1| }
31| 1| abort ();
32| 1|}
This bug is similar to bug 51003, I am not sure whether they belong to the same
bug.
Line 25 should be executed once. Line 27 and 29 should not be executed.
--
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/96720bee/attachment-0001.html>
More information about the llvm-bugs
mailing list