brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 499dcaf Raw
60 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.1 as a fragment of main14  .text15  .globl main16  .type main, %function17  .p2align 218main:19LBB0:20  andl $0xf, %ecx21  cmpb $0x4, %cl22  ## exit through ret23  ja LBB324 25## jump table dispatch, jumping to label indexed by val in %ecx26LBB1:27  leaq JUMP_TABLE(%rip), %r828  movzbl %cl, %ecx29  movslq (%r8,%rcx,4), %rax30  addq %rax, %r831  jmpq *%r832 33LBB2:34  xorq %rax, %rax35LBB3:36  addq $0x8, %rsp37  ret38.size main, .-main39 40## cold fragment is only reachable through jump table41  .globl main.cold.142  .type main.cold.1, %function43  .p2align 244main.cold.1:45  ## load bearing nop: pad LBB4 so that it can't be treated46  ## as __builtin_unreachable by analyzeJumpTable47  nop48LBB4:49  callq abort50.size main.cold.1, .-main.cold.151 52  .rodata53## jmp table, entries must be R_X86_64_PC32 relocs54  .globl JUMP_TABLE55JUMP_TABLE:56  .long LBB2-JUMP_TABLE57  .long LBB3-JUMP_TABLE58  .long LBB4-JUMP_TABLE59  .long LBB3-JUMP_TABLE60