xref: /llvm-project/bolt/test/runtime/X86/hot-end-symbol.s (revision bb627b0a0c05e0bb04ae7f984b8e7fcd84906061)
1# This reproduces a bug where BOLT would read __hot_end as
2# the name of a function even when -hot-text is used, which
3# means BOLT will emit another __hot_end label, eventually
4# asserting due to a symbol redefinition in MCStreamer.
5
6# REQUIRES: system-linux
7
8# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
9# RUN:   %s -o %t.o
10# RUN: link_fdata %s %t.o %t.fdata
11# RUN: llvm-strip --strip-unneeded %t.o
12# RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q
13
14# RUN: llvm-bolt %t.exe --relocs=1 --hot-text --reorder-functions=hfsort \
15# RUN:    --split-functions --split-strategy=all \
16# RUN:    --data %t.fdata -o %t.out | FileCheck %s
17
18# RUN: %t.out 1
19
20# CHECK: BOLT-INFO: setting __hot_end to
21
22# RUN: llvm-nm -n %t.exe | FileCheck %s --check-prefix=CHECK-INPUT
23# RUN: llvm-nm -n %t.out | FileCheck %s --check-prefix=CHECK-OUTPUT
24
25# CHECK-INPUT:       __hot_start
26# CHECK-INPUT-NEXT:  main
27# CHECK-INPUT-NEXT:  foo
28# CHECK-INPUT-NEXT:  __hot_end
29
30# Our fdata only logs activity in main, so hot markers will change
31# CHECK-OUTPUT:       __hot_start
32# CHECK-OUTPUT-NEXT:  main
33# CHECK-OUTPUT-NEXT:  __hot_end
34# CHECK-OUTPUT-NOT:   __hot_start.cold
35
36  .text
37  .globl  main
38  .type main, %function
39  .globl  __hot_start
40  .p2align  4
41main:
42__hot_start:
43# FDATA: 0 [unknown] 0 1 main 0 0 510
44  pushq %rbp
45  movq  %rsp, %rbp
46  cmpl  $0x2, %edi
47  jb    .BBend
48.BB2:
49  callq bar
50  leaq mystring, %rdi
51  callq puts
52
53.BBend:
54  xorq %rax, %rax
55  leaveq
56  retq
57  .size main, .-main
58
59  .globl foo
60  .type foo, %function
61  .p2align 4
62foo:
63  retq
64  .size foo, .-foo
65
66  .globl __hot_end
67  .type __hot_end, %object
68  .p2align 2
69__hot_end:
70  int3
71  .size __hot_end, 0
72
73  .globl bar
74  .type bar, %function
75  .p2align 4
76bar:
77  retq
78  .size bar, .-bar
79
80  .data
81mystring: .asciz "test\n"
82