<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 - [inline assembly] "p" constraint is not always a valid address"
href="https://bugs.llvm.org/show_bug.cgi?id=45168">45168</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[inline assembly] "p" constraint is not always a valid address
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</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>Keywords</th>
<td>compile-fail, miscompilation
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>frederic.recoules@univ-grenoble-alpes.fr
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Consider the following (useless) code:
int * f (int *p)
{
__asm__ ("leal %a1, %0" : "=r" (p) : "p" (p));
return p;
}
Which produces the following IR:
define dso_local i32* @f(i32* readnone) local_unnamed_addr #0 !dbg !8 {
call void @llvm.dbg.value(metadata i32* %0, metadata !15, metadata
!DIExpression()), !dbg !16
%2 = tail call i32* asm "leal ${1:a}, $0",
"=r,im,~{dirflag},~{fpsr},~{flags}"(i32* %0) #2, !dbg !17, !srcloc !18
call void @llvm.dbg.value(metadata i32* %2, metadata !15, metadata
!DIExpression()), !dbg !16
ret i32* %2, !dbg !19
}
We can see that "p" has been translated to "im". It is true from at least clang
3.0 to at least 9.0 (tested on <a href="https://godbolt.org/">https://godbolt.org/</a>).
But "p" definition is "An operand that is a valid memory address is allowed.".
Correct me, but "m" is not a valid memory address as it is already a memory
access.
I think a non-optimal way to encode "p" would rather be "ir" as both constant
and register can be part of an address, but it would miss complex addresses
like "%ebp + 4 * %eax - 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>