<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 --- - Strange handling of asm constraints"
href="http://llvm.org/bugs/show_bug.cgi?id=17959">17959</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Strange handling of asm constraints
</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>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>marc.glisse@normalesup.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>double f(double x){
asm volatile ("" : "+x"(x) );
asm volatile ("" : "+m"(x) );
asm volatile ("" : "+f"(x) );
asm volatile ("" : "+mx"(x) );
asm volatile ("" : "+mf"(x) );
asm volatile ("" : "+xm"(x) );
asm volatile ("" : "+xf"(x) );
asm volatile ("" : "+fx"(x) );
asm volatile ("" : "+fm"(x) );
asm volatile ("" : "+mxf"(x) );
asm volatile ("" : "+mfx"(x) );
asm volatile ("" : "+fmx"(x) );
asm volatile ("" : "+fxm"(x) );
asm volatile ("" : "+xfm"(x) );
asm volatile ("" : "+xmf"(x) );
return x;
}
compiled with clang complains:
error: illegal "f" output constraint
for each line where there isn't an 'x' before the 'f'. That seems inconsistent.
And the 'f' seems ignored in the cases where it isn't rejected.
Now if I compile:
asm volatile ("" : "+x"(x) );
with -m64 -O, I get the expected empty assembler output (just 'ret').
But with "+xm", the compiler somehow adds:
movsd %xmm0, -8(%rsp)
before and after the asm (I would maybe understand if the second movsd was
reversed, it would just mean that llvm wrongly prefers 'm' to 'x', but the same
movsd is confusing me).
Similarly strange things happen with -m32, producing for instance:
subl $12, %esp
movsd 16(%esp), %xmm0
movsd %xmm0, (%esp)
#APP
#NO_APP
movsd %xmm0, (%esp)
fldl (%esp)
addl $12, %esp
when with just "+x" it manages the less strange:
subl $12, %esp
movsd 16(%esp), %xmm0
#APP
#NO_APP
movsd %xmm0, (%esp)
fldl (%esp)
addl $12, %esp
ret
Note that inline asm is all the more necessary with llvm ignoring fenv floating
point support.</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>