brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 634a45b Raw
67 lines · plain
1## This reproduces a bug with jump table identification where jump table has2## entries pointing to code in function and its cold fragment.3## The fragment is only reachable through jump table.4 5# REQUIRES: system-linux6 7# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o8# RUN: llvm-strip --strip-unneeded %t.o9# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q10# RUN: llvm-bolt %t.exe -o %t.out --lite=0 -v=1 2>&1 | FileCheck %s11 12# CHECK-NOT: unclaimed PC-relative relocations left in data13# CHECK: BOLT-INFO: marking main.cold as a fragment of main14  .text15  .globl _start16  .type _start, %function17_start:18  callq main.cold19  call exit20.size _start, .-_start21 22  .globl main.cold23  .type main.cold, %function24  .p2align 225main.cold:26LBB0:27  andl $0xf, %ecx28  cmpb $0x4, %cl29  ## exit through ret30  ja LBB331 32## jump table dispatch, jumping to label indexed by val in %ecx33LBB1:34  leaq JUMP_TABLE(%rip), %r835  movzbl %cl, %ecx36  movslq (%r8,%rcx,4), %rax37  addq %rax, %r838  jmpq *%r839 40LBB2:41  xorq %rax, %rax42LBB3:43  addq $0x8, %rsp44  ret45.size main.cold, .-main.cold46 47## main function, referenced from jump table in cold fragment48  .globl main49  .type main, %function50  .p2align 251main:52  ## load bearing nop: pad LBB4 so that it can't be treated53  ## as __builtin_unreachable by analyzeJumpTable54  nop55LBB4:56  callq abort57.size main, .-main58 59  .rodata60## jmp table, entries must be R_X86_64_PC32 relocs61  .globl JUMP_TABLE62JUMP_TABLE:63  .long LBB2-JUMP_TABLE64  .long LBB3-JUMP_TABLE65  .long LBB4-JUMP_TABLE66  .long LBB3-JUMP_TABLE67