<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 - clang crash with inline asm that has function type as input operand"
href="https://bugs.llvm.org/show_bug.cgi?id=51081">51081</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang crash with inline asm that has function type as input operand
</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>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jasonliu.development@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Reduced test case:
```
void callee(void);
void caller() {
asm volatile("rcall %0"::"n"(callee));
}
```
Without assertion, compiler crashes in llvm and getting stack dump:
<a href="https://godbolt.org/z/hb4acs8aG">https://godbolt.org/z/hb4acs8aG</a>
With assertion turned on, compiler hit
`assert(!LV.getType()->isFunctionType());` in
`CodeGenFunction::EmitLoadOfLValue()` clang/lib/CodeGen/CGExpr.cpp.
So it seems we might already generated wrong IR from clang which leads to the
crash in LLVM (in non-assert mode).
The easy change would be to reverse part of this fix:
<a href="https://github.com/llvm/llvm-project/commit/d68b2d043865e1c106432f2ab9c1b99a5a2ba86e">https://github.com/llvm/llvm-project/commit/d68b2d043865e1c106432f2ab9c1b99a5a2ba86e</a>
i.e. to remove the assertion and bring back the if statement.
But it seems that we might prefer to have a sema component change (i.e. detect
if it's a function then do a function to pointer decay) instead of waiting to
change it in the last minute of clang code gen.</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>