<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 --- - clang misassembles 16-bit operations"
href="http://llvm.org/bugs/show_bug.cgi?id=18220">18220</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang misassembles 16-bit operations
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>3.3
</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>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>dwmw2@infradead.org
</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>I was trying to familiarise myself with the code, wondering if I was stupid
enough to try to fix <a class="bz_bug_link
bz_status_NEW "
title="NEW --- - False positives due to a coding style with invariants"
href="show_bug.cgi?id=8464">bug 8464</a>. I couldn't work out how the current code could
work in all cases even for 32-bit mode.
Turns out it doesn't. We always emit 4 bytes of displacement, even when we've
emitted the 0x67 prefix and should only be emitting *2* bytes of displacement.
And we end up using the wrong registers too, since we use the ModR/M table for
32-bit mode when we should be using the 16-bit one.
Consider this test case, compiled with '-m32 -c -o foo.o foo.S'
movw $0x55aa, 0x1234(%bp)
GCC quite correctly gives the following:
00000000 <.text>:
0: 67 66 c7 86 34 12 aa movw $0x55aa,0x1234(%bp)
7: 55
But clang gives this erroneous output:
00000000 <.text>:
0: 67 66 c7 85 34 12 00 movw $0x0,0x1234(%di)
7: 00
8: aa stos %al,%es:(%edi)
9: 55 push %ebp</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>