[llvm-bugs] [Bug 50839] New: [LLVM-COV] Dead code following a call site has wrong coverage.
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jun 24 01:40:49 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50839
Bug ID: 50839
Summary: [LLVM-COV] Dead code following a call site has wrong
coverage.
Product: Runtime Libraries
Version: 11.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
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>
typedef unsigned int dev_t;
typedef unsigned int kdev_t;
static inline kdev_t to_kdev_t(int dev) {
int major, minor;
if (sizeof(kdev_t) == 16)
return (kdev_t)dev;
major = (dev >> 8);
minor = (dev & 0xff);
return (((major) << 22) | (minor));
}
void do_mknod(const char *filename, int mode, kdev_t dev) {
if (dev == 0x15800078)
exit(0);
else
abort();
}
int sys_mknod(const char *filename, int mode, dev_t dev) {
int error;
char *tmp;
tmp = (char *)((unsigned int)filename*5+1);
error = ((long)(tmp));
do_mknod(tmp, mode, to_kdev_t(dev));
printf("Executed!\n");
return error;
}
int main(void) {
if (sizeof(int) != 4)
exit(0);
return sys_mknod("test", 1, 0x12345678);
}
$ 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| |typedef unsigned int dev_t;
3| |typedef unsigned int kdev_t;
4| |
5| 1|static inline kdev_t to_kdev_t(int dev) {
6| 1| int major, minor;
7| 1|
8| 1| if (sizeof(kdev_t) == 16)
9| 0| return (kdev_t)dev;
10| 1| major = (dev >> 8);
11| 1| minor = (dev & 0xff);
12| 1| return (((major) << 22) | (minor));
13| 1|}
14| |
15| 1|void do_mknod(const char *filename, int mode, kdev_t dev) {
16| 1| if (dev == 0x15800078)
17| 1| exit(0);
18| 0| else
19| 0| abort();
20| 1|}
21| |
22| 1|int sys_mknod(const char *filename, int mode, dev_t dev) {
23| 1| int error;
24| 1| char *tmp;
25| 1|
26| 1| tmp = (char *)((unsigned int)filename*5+1);
27| 1| error = ((long)(tmp));
28| 1| do_mknod(tmp, mode, to_kdev_t(dev));
29| 1| printf("Executed!\n");
30| 1| return error;
31| 1|}
32| |
33| 1|int main(void) {
34| 1| if (sizeof(int) != 4)
35| 0| exit(0);
36| 1|
37| 1| return sys_mknod("test", 1, 0x12345678);
38| 1|}
Line 29 and 30 were not executed.
--
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/20210624/beca9b4c/attachment-0001.html>
More information about the llvm-bugs
mailing list