<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] Code after "va_arg" was wrongly marked as executed."
href="https://bugs.llvm.org/show_bug.cgi?id=51266">51266</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[LLVM-COV] Code after "va_arg" was wrongly marked as executed.
</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>
#include <stdarg.h>
void __attribute__((noinline, noclone)) bar(int x, va_list *ap) {
if (ap) {
int i;
for (i = 0; i < 10; i++)
if (i != va_arg(*ap, int))
__builtin_abort();
if (va_arg(*ap, double) != 0.5)
__builtin_abort();
}
}
void __attribute__((noinline, noclone)) foo(int x, ...) {
va_list ap;
int n;
va_start(ap, x);
n = va_arg(ap, int);
bar(x, (va_list *)((n == 0) ? ((void *)0) : &ap));
va_end(ap);
}
int main() {
foo(100, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0.5);
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
1| |#include <stdio.h>
2| |#include <stdlib.h>
3| |#include <stdarg.h>
4| |
5| 1|void __attribute__((noinline, noclone)) bar(int x, va_list *ap) {
6| 1| if (ap) {
7| 1| int i;
8| 11| for (i = 0; i < 10; i++)
9| 10| if (i != va_arg(*ap, int))
10| 10| __builtin_abort();
11| 1| if (va_arg(*ap, double) != 0.5)
12| 0| __builtin_abort();
13| 1| }
14| 1|}
15| |
16| 1|void __attribute__((noinline, noclone)) foo(int x, ...) {
17| 1| va_list ap;
18| 1| int n;
19| 1|
20| 1| va_start(ap, x);
21| 1| n = va_arg(ap, int);
22| 1| bar(x, (va_list *)((n == 0) ? ((void *)0) : &ap));
23| 1| va_end(ap);
24| 1|}
25| |
26| 1|int main() {
27| 1| foo(100, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0.5);
28| 1| return 0;
29| 1|}
Line 10 was never executed.</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>