<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 - [AArch64] Using ".byte" from asm in a switch statement causes bad jump table"
href="https://bugs.llvm.org/show_bug.cgi?id=48255">48255</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[AArch64] Using ".byte" from asm in a switch statement causes bad jump table
</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>MacOS X
</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>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>myriachan@gmail.com
</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>Created <span class=""><a href="attachment.cgi?id=24196" name="attach_24196" title="Compile me with -O2 on ARM64">attachment 24196</a> <a href="attachment.cgi?id=24196&action=edit" title="Compile me with -O2 on ARM64">[details]</a></span>
Compile me with -O2 on ARM64
If you use .byte from within an ARM64 "asm" block to exceed 4 bytes per line, a
"switch" statement could generate a bad jump table, causing unpredictable
behavior. This happens with -O1 and higher, but is more likely with -O2 and
higher.
<a href="https://gcc.godbolt.org/z/bGdqb3">https://gcc.godbolt.org/z/bGdqb3</a>
The correct output is 1 (i.e. 15 - 14), but instead it prints 29 on ARM64 with
-O2 because the CPU ends up riding the NOP sled.
What happens is that LLVM with -O2 or higher will use a byte-sized table to
store a count of instructions to skip for that entry of the jump table. When
LLVM inlines Meow, this exceeds the values that can be stored in this jump
table, truncating the jump distance to a byte.</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>