56 lines · plain
1# This reproduces a bug with instrumentation when trying to instrument2# a function with only tail calls. Such functions can clobber red zone,3# see https://github.com/llvm/llvm-project/issues/61114.4 5# REQUIRES: system-linux,bolt-runtime6 7# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o8# RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q9 10# RUN: llvm-bolt %t.exe --instrument --instrumentation-file=%t.fdata \11# RUN: -o %t.instrumented12# RUN: %t.instrumented arg1 arg213# RUN: llvm-objdump %t.instrumented --disassemble-symbols=main | FileCheck %s14 15# CHECK: leaq 0x80(%rsp), %rsp16 17# RUN: FileCheck %s --input-file %t.fdata --check-prefix=CHECK-FDATA18# CHECK-FDATA: 1 main {{.*}} 1 targetFunc 0 0 119 20 .text21 .globl main22 .type main, %function23 .p2align 424main:25 pushq %rbp26 movq %rsp, %rbp27 mov %rax,-0x10(%rsp)28 leaq targetFunc, %rax29 pushq %rax # We save the target function address in the stack30 subq $0x18, %rsp # Set up a dummy stack frame31 cmpl $0x2, %edi32 jb .LBBerror # Add control flow so we don't have a trivial case33.LBB2:34 addq $0x20, %rsp35 movq %rbp, %rsp36 pop %rbp37 mov -0x10(%rsp),%rax38 test %rsp, %rsp39 jne targetFunc40 41.LBBerror:42 addq $0x20, %rsp43 movq %rbp, %rsp44 pop %rbp45 movq $1, %rax # Finish with an error if we go this path46 retq47 .size main, .-main48 49 .globl targetFunc50 .type targetFunc, %function51 .p2align 452targetFunc:53 xorq %rax, %rax54 retq55 .size targetFunc, .-targetFunc56