<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 the default label in switch statement"
href="https://bugs.llvm.org/show_bug.cgi?id=49427">49427</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[LLVM-COV] Wrong coverage with the default label in switch 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
void foo(int v, int w) {
int i;
if (w) {
goto do_default;
}
switch (v) {
case 0:
i = 27;
break;
case 1:
i = 8;
break;
default:
do_default:
i = 10;
break;
}
}
int main(){
int i;
for(i=0;i<6;i++){
if(i<4)
foo(i,0);
else
foo(i,1);
}
}
$ 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| 6|void foo(int v, int w) {
2| 6| int i;
3| 6| if (w) {
4| 2| goto do_default;
5| 2| }
6| 4| switch (v) {
7| 1| case 0:
8| 1| i = 27;
9| 1| break;
10| 1| case 1:
11| 1| i = 8;
12| 1| break;
13| 4| default:
14| 4| do_default:
15| 4| i = 10;
16| 4| break;
17| 4| }
18| 4|}
19| |
20| 1|int main(){
21| 1|int i;
22| 7|for(i=0;i<6;i++){
23| 6| if(i<4)
24| 4| foo(i,0);
25| 2| else
26| 2| foo(i,1);
27| 6|}
28| 1|}
Line #13 should be executed twice instead of 4 times</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>