[llvm-bugs] [Bug 49483] New: [LLVM-COV] When the function pointer is used as a parameter, the coverage igoes wrong
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Mar 9 00:12:21 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=49483
Bug ID: 49483
Summary: [LLVM-COV] When the function pointer is used as a
parameter, the coverage igoes wrong
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
#include<stdio.h>
void free(void *ptr) {
printf("passed\n");
}
void *foo(void) {
printf("return\n");
return 0;
}
int main(void) {
void *p = foo();
free(p);
return 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
passed
return
passed
passed
passed
1| |#include<stdio.h>
2| 2|void free(void *ptr) {
3| 2|printf("passed\n");
4| 2|}
5| |
6| 1|void *foo(void) {
7| 1|printf("return\n");
8| 1|return 0;
9| 1|}
10| |
11| 1|int main(void) {
12| 1| void *p = foo();
13| 1| free(p);
14| 1| return 0;
15| 1|}
The result shows that function "free" was executed 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/20210309/f7892889/attachment.html>
More information about the llvm-bugs
mailing list