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: unassignedclangb...@nondot.org
          Reporter: myriac...@gmail.com
                CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
                    richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to