[llvm-bugs] [Bug 51022] New: [llvm-cov] wrong coverage for a return statement with ternary operator
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jul 8 05:01:51 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51022
Bug ID: 51022
Summary: [llvm-cov] wrong coverage for a return statement with
ternary operator
Product: Runtime Libraries
Version: 12.0
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: libprofile library
Assignee: unassignedbugs at nondot.org
Reporter: byone.heng at gmail.com
CC: llvm-bugs at lists.llvm.org
$./clang -v
clang version 12.0.0 (https://github.com/llvm/llvm-project.git
b6c8feb29fce39121884f7e08ec6eb0f58da3fb7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/x/project/llvm-project/build/install/bin/.
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
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
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$cat test.c
———————————————————
static volatile signed char true_var = 1;
static const volatile signed char false_var = 0;
extern void abort ();
int f(int x)
{
return (x >> (sizeof (x) * __CHAR_BIT__ - 1)) ? -1 : 1;
}
volatile int one = 1;
int main (void)
{
/* Test that the function above returns different values for
different signs. */
if (f(one) == f(-one))
abort ();
return 0;
}
——————————————————
$clang -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
2| |static volatile signed char true_var = 1;
3| |static const volatile signed char false_var = 0;
4| |extern void abort ();
5| |
6| |int f(int x)
7| 2|{
8| 1| return (x >> (sizeof (x) * __CHAR_BIT__ - 1)) ? -1 : 1;
9| 2|}
10| |
11| |volatile int one = 1;
12| |int main (void)
13| 1|{
14| | /* Test that the function above returns different values for
15| | different signs. */
16| 1| if (f(one) == f(-one))
17| 0| abort ();
18| 1| return 0;
19| 1|}
20| |
Line 8 should be executed twice.
--
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/20210708/15f74255/attachment.html>
More information about the llvm-bugs
mailing list