1 # REQUIRES: system-linux
3 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
4 # RUN: llvm-strip --strip-unneeded %t.o
5 # RUN: %clang %cflags -no-pie -nostartfiles -nostdlib -lc %t.o -o %t.exe -Wl,-q
7 # RUN: llvm-bolt %t.exe -o %t.exe.bolt --relocs=1 --lite=0
11 ## Check that BOLT's jump table detection diffrentiates between
12 ## __builtin_unreachable() targets and function pointers.
14 ## The test case was built from the following two source files and
15 ## modiffied for standalone build. main became _start, etc.
16 ## $ $(CC) a.c -O1 -S -o a.s
17 ## $ $(CC) b.c -O0 -S -o b.s
21 ## typedef int (*fptr)(int);
22 ## void check_fptr(fptr, int);
25 ## check_fptr(foo, 0);
28 ## __builtin_unreachable();
45 ## int main(int argc) {
46 ## check_fptr(main, 1);
50 ## const fptr funcs[2] = {foo, main};
54 ## typedef int (*fptr)(int);
55 ## extern const fptr funcs[2];
57 ## #define assert(C) { if (!(C)) (*(unsigned long long *)0) = 0; }
58 ## void check_fptr(fptr f, int i) {
59 ## assert(f == funcs[i]);
70 .cfi_def_cfa_offset 16
103 .type _start, @function
108 .cfi_def_cfa_offset 16
117 .cfi_def_cfa_offset 8
121 .size _start, .-_start
123 .type check_fptr, @function
128 .cfi_def_cfa_offset 16
131 .cfi_def_cfa_register 6
136 movq funcs
(,%rax
,8), %rax