[clang-repl] [codegen] Reduce the state in TBAA. NFC for static compilation. (#98138)
[llvm-project.git] / bolt / test / runtime / X86 / shrinkwrapping-alignment.s
blob1a16b40b0f8bfd191366ea480525505c6d8050f2
1 # This reproduces a bug with shrink wrapping when trying to move
2 # push-pops in a function where we are not allowed to modify the
3 # stack layout for alignment reasons. In this bug, we failed to
4 # propagate alignment requirement upwards in the call graph for
5 # some functions when there is a cycle in the call graph.
7 # REQUIRES: system-linux
9 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
10 # RUN: %s -o %t.o
11 # RUN: link_fdata %s %t.o %t.fdata
12 # Delete our BB symbols so BOLT doesn't mark them as entry points
13 # RUN: llvm-strip --strip-unneeded %t.o
14 # RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q
16 # RUN: llvm-bolt %t.exe --relocs=1 --frame-opt=all --print-finalized \
17 # RUN: --lite=0 --print-only=main --data %t.fdata -o %t.out | FileCheck %s
19 # RUN: %t.out
21 # CHECK: BOLT-INFO: Shrink wrapping moved 1 spills inserting load/stores and 0 spills inserting push/pops
23 .text
24 .globl bar
25 .type bar, %function
26 .p2align 4
27 bar:
28 # FDATA: 0 [unknown] 0 1 bar 0 0 510
29 pushq %rbp
30 movq %rsp, %rbp
31 pushq %rbx # We save rbx here, but there is an
32 # opportunity to move it to .BB2
33 subq $0x18, %rsp
34 cmpl $0x2, %edi
35 .J1:
36 jb .BBend
37 # FDATA: 1 bar #.J1# 1 bar #.BB2# 0 10
38 # FDATA: 1 bar #.J1# 1 bar #.BBend# 0 500
39 .BB2:
40 movq $2, %rbx # Use rbx in a cold block
41 xorq %rax, %rax
42 movb mystring, %al
43 addq %rbx, %rax
44 movb %al, mystring
45 leaq mystring, %rdi
46 #callq puts
48 .BBend:
49 addq $0x18, %rsp
50 pop %rbx # Restore
51 xorq %rax, %rax
52 cmpq $0x0, %rax
53 jne .BBnever
54 jmp .BBbarend
55 .BBnever:
56 # This is a path that is never executed, but we add a call to main here
57 # to force a cycle in the call graph and to require us to have an aligned
58 # stack
59 callq main
60 .BBbarend:
61 leaveq
62 retq
63 .size bar, .-bar
65 # Frame alignedness information needs to be transmitted from foo to main to bar
66 .globl main
67 .type main, %function
68 .p2align 4
69 main:
70 # Call a function that requires an aligned stack
71 callq foo
72 # Call a function that can be shrink-wrapped
73 callq bar
74 retq
75 .size main, .-main
77 # Frame alignedness information needs to be transmitted from foo to main to bar
78 .globl foo
79 .type foo, %function
80 .p2align 4
81 foo:
82 # Use an instruction that requires an aligned stack
83 movdqa -0x10(%rsp), %xmm0
84 retq
85 .size foo, .-foo
87 .data
88 mystring: .asciz "0 is rbx mod 10 contents in decimal\n"