<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 in "if" branch structure."
href="https://bugs.llvm.org/show_bug.cgi?id=50857">50857</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[LLVM-COV] Wrong coverage in "if" branch structure.
</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>enhancement
</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
#include<stdio.h>
#include<stdlib.h>
#define F 140
#define T 13
feq(x, y) long long int x;
long long int y;
{
if (x == y)
return T;
else
return F;
}
long long args[] = {0LL,1LL,-1LL};
int correct_results[] = {
T, F, F, T};
main() {
int i, j, *res = correct_results;
for (i = 0; i < 2; i++) {
long long arg0 = args[i];
for (j = 0; j < 2; j++) {
long long arg1 = args[j];
if (feq(arg0, arg1) != *res++)
abort();
}
}
exit(0);
}
$ 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| |#include<stdio.h>
2| |#include<stdlib.h>
3| 2|#define F 140
4| 2|#define T 13
5| |
6| |feq(x, y) long long int x;
7| |long long int y;
8| 4|{
9| 4| if (x == y)
10| 2| return T;
11| 4| else
12| 4| return F;
13| 4|}
14| |
15| |
16| |long long args[] = {0LL,1LL,-1LL};
17| |
18| |int correct_results[] = {
19| | T, F, F, T};
20| |
21| 1|main() {
22| 1| int i, j, *res = correct_results;
23| 1|
24| 3| for (i = 0; i < 2; i++) {
25| 2| long long arg0 = args[i];
26| 6| for (j = 0; j < 2; j++) {
27| 4| long long arg1 = args[j];
28| 4| if (feq(arg0, arg1) != *res++)
29| 0| abort();
30| 4| }
31| 2| }
32| 1| exit(0);
33| 1|}
34| |
Line 12 should only be executed 2 times, and I'm not sure if the coverage of
line 3 and 4 is 2.</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>