<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 - Invalid counters with a switch statement"
href="https://bugs.llvm.org/show_bug.cgi?id=38821">38821</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Invalid counters with a switch statement
</td>
</tr>
<tr>
<th>Product</th>
<td>compiler-rt
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>profile
</td>
</tr>
<tr>
<th>Assignee</th>
<td>cdenizet@mozilla.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>cdenizet@mozilla.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mcastelluccio@mozilla.com
</td>
</tr></table>
<p>
<div>
<pre>Here is the C code:
int main(void)
{
int i = 22;
switch (i) {
case 7:
break;
case 22:
i = 7;
break;
case 42:
break;
}
return 0;
}
The .c.gcov is:
-: 0:Source:sl.c
-: 0:Graph:sl.gcno
-: 0:Data:sl.gcda
-: 0:Runs:1
-: 0:Programs:1
-: 1:int main(void)
-: 2:{
2: 3: int i = 22;
-: 4:
2: 5: switch (i) {
-: 6: case 7:
#####: 7: break;
-: 8:
-: 9: case 22:
1: 10: i = 7;
1: 11: break;
-: 12:
-: 13: case 42:
#####: 14: break;
-: 15: }
-: 16:
1: 17: return 0;
-: 18:}
Notice the 2 on lines 3 and 5.
And a gcda dump gives:
===== main (0) @ sl.c:1
Block : 0 Counter : 1
Destination Edges : 1 (1),
Block : 1 Counter : 2
Source Edges : 0 (1),
Destination Edges : 2 (0), 3 (1), 4 (0), 5 (1),
Lines : 3,5,
Block : 2 Counter : 0
Source Edges : 1 (0),
Destination Edges : 5 (0),
Lines : 7,
Block : 3 Counter : 1
Source Edges : 1 (1),
Destination Edges : 5 (1),
Lines : 10,11,
Block : 4 Counter : 0
Source Edges : 1 (0),
Destination Edges : 5 (0),
Lines : 14,
Block : 5 Counter : 1
Source Edges : 1 (1), 2 (0), 3 (1), 4 (0),
Destination Edges : 6 (1),
Lines : 17,
Block : 6 Counter : 1
Source Edges : 5 (1),
File 'sl.c'
Lines executed:71.43% of 7
sl.c:creating 'sl.c.gcov'
The block 1 has a branch to block 5, but this branch is not taken so the
counter for 1->5 must be 0.</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>