xref: /llvm-project/bolt/test/X86/bolt-address-translation-internal-call.test (revision 11791ae7b0b05b8bd8d806331ff51da618912cf8)
1## This checks for an issue with internal calls and BAT (BOLT address
2## translation). BAT needs to map every output block back to an input
3## block, but passes that introduce new blocks (such as validate
4## internal calls) might create new blocks without a mapping to an
5## input block.
6
7# REQUIRES: x86_64-linux,bolt-runtime
8
9# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
10# Delete our BB symbols so BOLT doesn't mark them as entry points
11# RUN: llvm-strip --strip-unneeded %t.o
12# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
13
14# RUN: llvm-bolt --enable-bat %t.exe --relocs -o %t.out | FileCheck %s
15# CHECK: BOLT-INFO: Wrote {{.*}} BAT maps
16
17# RUN: llvm-bat-dump %t.out --dump-all | \
18# RUN:   FileCheck %s --check-prefix=CHECK-BAT-DUMP
19# CHECK-BAT-DUMP:  BAT tables for {{.*}} functions
20
21  .text
22  .globl  main
23  .type main, %function
24  .p2align  4
25main:
26  push   %rbp
27  mov    %rsp,%rbp
28  push   %r12
29  push   %rbx
30  sub    $0x120,%rsp
31  mov    $0x3,%rbx
32  movq   rel(%rip), %rdi
33.J1:
34  cmp    $0x0,%rbx
35  je     .J2
36  callq  .J3
37  nopl   (%rax,%rax,1)
38  movabs $0xdeadbeef,%rax
39  retq
40.J2:
41  add    $0x120,%rsp
42  pop    %rbx
43  pop    %r12
44  jmp    .J4
45.J3:
46  pop    %rax
47  add    $0x4,%rax
48  dec    %rbx
49  jmp    .J1
50.J4:
51  pop    %rbp
52  retq
53end:
54  .size main, .-main
55
56  .data
57rel: .quad end
58