1 # This checks that shrink wrapping uses the red zone defined in the X86 ABI by
2 # placing restores that access elements already deallocated by the stack.
4 # REQUIRES: system-linux
6 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
8 # RUN: link_fdata %s %t.o %t.fdata
9 # RUN: llvm-strip --strip-unneeded %t.o
10 # RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib
11 # RUN: llvm-bolt -relocs %t.exe -o %t.out -data %t.fdata \
12 # RUN: -frame-opt=all -simplify-conditional-tail-calls=false \
13 # RUN: -experimental-shrink-wrapping \
14 # RUN: -eliminate-unreachable=false | FileCheck %s
15 # RUN: llvm-objdump -d %t.out --print-imm-hex | \
16 # RUN: FileCheck --check-prefix CHECK-OBJDUMP %s
19 # Here we create a CFG where the restore position matches the previous (deleted)
20 # restore position. Shrink wrapping then will put a stack access to an element
21 # that was deallocated at the previously deleted POP, which falls in the red
22 # zone and should be safe for X86 Linux ABI.
24 .type _start, %function
27 # FDATA: 0 [unknown] 0 1 _start 0 0 1
34 # FDATA: 1 _start #b# 1 _start #hot_path# 0 1
38 movq rel
(%rip
), %rdi
# Add this to create a relocation and run bolt w/ relocs
39 leaq
-0x20(%rbp
), %r14
40 movq
-0x20(%rbp
), %rdi
41 leaq
-0x10(%rbp
), %rsp
54 .size _start, .-_start
59 # CHECK: BOLT-INFO: Shrink wrapping moved 2 spills inserting load/stores and 0 spills inserting push/pops
61 # CHECK-OBJDUMP: <_start>:
62 # CHECK-OBJDUMP: leaq (%rbp), %rsp
63 # CHECK-OBJDUMP-NEXT: popq %rbp
64 # CHECK-OBJDUMP-NEXT: movq -0x10(%rsp), %rbx
65 # CHECK-OBJDUMP-NEXT: movq -0x18(%rsp), %r14
66 # CHECK-OBJDUMP-NEXT: retq