[clang-repl] [codegen] Reduce the state in TBAA. NFC for static compilation. (#98138)
[llvm-project.git] / bolt / test / runtime / X86 / instrumentation-tail-call.s
blobdfb12f03401a3ab27d8bd6a55bc1c1416baa5e1e
1 # This reproduces a bug with instrumentation when trying to instrument
2 # a function with only tail calls. Such functions can clobber red zone,
3 # see https://github.com/llvm/llvm-project/issues/61114.
5 # REQUIRES: system-linux,bolt-runtime
7 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
8 # RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q
10 # RUN: llvm-bolt %t.exe --instrument --instrumentation-file=%t.fdata \
11 # RUN: -o %t.instrumented
12 # RUN: %t.instrumented arg1 arg2
13 # RUN: llvm-objdump %t.instrumented --disassemble-symbols=main | FileCheck %s
15 # CHECK: leaq 0x80(%rsp), %rsp
17 # RUN: FileCheck %s --input-file %t.fdata --check-prefix=CHECK-FDATA
18 # CHECK-FDATA: 1 main {{.*}} 1 targetFunc 0 0 1
20 .text
21 .globl main
22 .type main, %function
23 .p2align 4
24 main:
25 pushq %rbp
26 movq %rsp, %rbp
27 mov %rax,-0x10(%rsp)
28 leaq targetFunc, %rax
29 pushq %rax # We save the target function address in the stack
30 subq $0x18, %rsp # Set up a dummy stack frame
31 cmpl $0x2, %edi
32 jb .LBBerror # Add control flow so we don't have a trivial case
33 .LBB2:
34 addq $0x20, %rsp
35 movq %rbp, %rsp
36 pop %rbp
37 mov -0x10(%rsp),%rax
38 test %rsp, %rsp
39 jne targetFunc
41 .LBBerror:
42 addq $0x20, %rsp
43 movq %rbp, %rsp
44 pop %rbp
45 movq $1, %rax # Finish with an error if we go this path
46 retq
47 .size main, .-main
49 .globl targetFunc
50 .type targetFunc, %function
51 .p2align 4
52 targetFunc:
53 xorq %rax, %rax
54 retq
55 .size targetFunc, .-targetFunc