[llvm-bugs] [Bug 48255] New: [AArch64] Using ".byte" from asm in a switch statement causes bad jump table
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Nov 21 18:12:18 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=48255
Bug ID: 48255
Summary: [AArch64] Using ".byte" from asm in a switch statement
causes bad jump table
Product: clang
Version: trunk
Hardware: PC
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: myriachan at gmail.com
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
Created attachment 24196
--> https://bugs.llvm.org/attachment.cgi?id=24196&action=edit
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.
https://gcc.godbolt.org/z/bGdqb3
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201122/c0fee482/attachment.html>
More information about the llvm-bugs
mailing list