<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - while+switch at -O2 mixes up line info"
href="http://llvm.org/bugs/show_bug.cgi?id=22110">22110</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>while+switch at -O2 mixes up line info
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>paul_robinson@playstation.sony.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=13641" name="attach_13641" title="Sample source">attachment 13641</a> <a href="attachment.cgi?id=13641&action=edit" title="Sample source">[details]</a></span>
Sample source
Compiling the attached source with -O2 -g (or -gline-tables-only) and
the line info for the head of the while loop gets pretty confused.
Two instructions basically have their line info swapped, and another
instruction at the top of a block has no info at all.
The relevant source fragment is this (pData is a char*, Op is an enum):
/*25*/ while (1) {
/*26*/ Op op = static_cast<Op>(*pData++);
/*27*/ switch (op) {
which for me generated the following... note that
.LBB0_8 is one case of the switch, which was laid out above the
top of the loop--that's fine--but the line info clearly isn't right.
I added some annotations to help point out the problem.
## This is the case from the switch, which is fine.
.LBB0_8: # %if.then
# in Loop: Header=BB0_1 Depth=1
.loc 1 47 11 prologue_end # bz92041.cpp:47:11
.Ltmp1:
movswq 1(%rsi), %rcx
leaq 3(%rcx,%rsi), %rdi
.LBB0_1: # %while.body
# =>This Inner Loop Header: Depth=1
## NO LINE INFO HERE--1st instr of loop body inherits from prior basic block
movq %rdi, %rsi
## WRONG LINE INFO HERE--Load of *pData has line info for switch()
.loc 1 27 5 # bz92041.cpp:27:5
movzbl (%rsi), %ecx
## WRONG LINE INFO HERE--Range-check has line info for the load
.loc 1 26 29 # bz92041.cpp:26:29
cmpq $3, %rcx
.loc 1 27 5 # bz92041.cpp:27:5
ja .LBB0_9
# BB#2: # %while.body
# in Loop: Header=BB0_1 Depth=1
## Post-increment (*pData++) has correct line info
.loc 1 26 30 # bz92041.cpp:26:30
leaq 1(%rsi), %rdi
## WRONG LINE INFO HERE--switch dispatch inherits from previous instr
jmpq *.LJTI0_0(,%rcx,8)</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>