[llvm-bugs] [Bug 49427] New: [LLVM-COV] Wrong coverage with the default label in switch statement
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Mar 3 23:40:38 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=49427
Bug ID: 49427
Summary: [LLVM-COV] Wrong coverage with the default label in
switch statement
Product: Runtime Libraries
Version: 11.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: libprofile library
Assignee: unassignedbugs at nondot.org
Reporter: cnwy1996 at outlook.com
CC: llvm-bugs at lists.llvm.org
$ 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
--
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/20210304/7e81216a/attachment.html>
More information about the llvm-bugs
mailing list