Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / bolt / test / runtime / X86 / reg-reassign-swap-cold.s
blob115b5b0eeff8b504f31e2e629dca7eea870ba064
1 # This test case reproduces a bug where, during register swapping,
2 # the code fragments associated with the function need to be swapped
3 # together (which may be generated during PGO optimization). If not
4 # handled properly, optimized binary execution can result in a segmentation fault.
6 # REQUIRES: system-linux
8 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
9 # RUN: link_fdata %s %t.o %t.fdata
10 # RUN: llvm-strip --strip-unneeded %t.o
11 # RUN: %clang -no-pie %t.o -o %t.exe -Wl,-q
12 # RUN: llvm-bolt %t.exe -o %t.out -data=%t.fdata --reg-reassign | FileCheck %s
13 # RUN: %t.out
15 # CHECK: BOLT-INFO: Reg Reassignment Pass Stats
16 # CHECK-NEXT: 2 functions affected.
17 .text
18 .globl main
19 .globl main.cold
20 .p2align 4, 0x90
21 .type main,@function
22 .type main.cold,@function
23 main.cold:
24 bb1:
25 cmp $0x3, %r12
26 jne bb8
27 bb2:
28 jmp bb4
29 main: # @main
30 .cfi_startproc
31 # %bb.0: # %entry
32 pushq %rax
33 pushq %r12
34 pushq %rbx
35 .cfi_def_cfa_offset 16
36 mov $0x1, %r12
37 mov $0x2, %rbx
38 add $0x1, %r12
39 shr $0x14, %r12
40 mov $0x3, %r12
41 bb3:
42 jmp bb1
43 bb4:
44 cmp $0x3, %r12
45 bb5:
46 jne bb8
47 bb6:
48 xorl %eax, %eax
49 bb7:
50 popq %rcx
51 popq %rbx
52 popq %r12
53 .cfi_def_cfa_offset 8
54 retq
55 bb8:
56 mov $0x1, %rax
57 jmp bb7
58 # FDATA: 1 main.cold #bb2# 1 main #bb4# 0 100
59 # FDATA: 1 main #bb5# 1 main #bb6# 0 100
60 # FDATA: 1 main #bb3# 1 main.cold 0 0 100
62 .Lfunc_end0:
63 .size main, .Lfunc_end0-main
64 .cfi_endproc