<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [LLVM-COV] Wrong coverage with for statement"
href="https://bugs.llvm.org/show_bug.cgi?id=49428">49428</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[LLVM-COV] Wrong coverage with for statement
</td>
</tr>
<tr>
<th>Product</th>
<td>Runtime Libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>11.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>libprofile library
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>cnwy1996@outlook.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>$ clang -v
clang version 11.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/wangyang/llvm-project/build/bin
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
Selected multilib: .;@m64
$ cat test.c
int a, b, c, e, f;
void fn1(int p) {}
int fn2(int p) { return a ? p % a : 0; }
short fn3(int p) { return (1 >> p) < 1 ? 1 : p; }
int fn4() {
int g = 0, h = 1;
if (b)
goto lbl;
fn2(0);
if (fn3(1))
fn1(e && c);
if (h) {
int i = 1;
lbl:
if (i)
return 0;
for (; g < 1; g++)
;
}
for (;;)
f || g > 0;
}
int main() {
fn4();
}
$ clang -w -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| |int a, b, c, e, f;
2| 1|void fn1(int p) {}
3| 1|int fn2(int p) { return a ? p % a : 0; }
4| 1|short fn3(int p) { return (1 >> p) < 1 ? 1 : p; }
5| 1|int fn4() {
6| 1| int g = 0, h = 1;
7| 1| if (b)
8| 0| goto lbl;
9| 1| fn2(0);
10| 1| if (fn3(1))
11| 1| fn1(e && c);
12| 1| if (h) {
13| 1| int i = 1;
14| 1| lbl:
15| 1| if (i)
16| 1| return 0;
17| 0| for (; g < 1; g++)
18| 0| ;
19| 0| }
20| 1| for (;;)
21| 0| f || g > 0;
22| 0|}
23| |
24| 1|int main() {
25| 1| fn4();
26| 1|}
The number of executions of line #20 should be 0, the same as line #17</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>