65 lines · plain
1# This reproduces a bug with shrink wrapping when moving2# load instructions in-between the lock prefix and another3# instruction (where the lock prefix applies).4 5# REQUIRES: system-linux6 7# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \8# RUN: %s -o %t.o9# RUN: link_fdata %s %t.o %t.fdata10# Delete our BB symbols so BOLT doesn't mark them as entry points11# RUN: llvm-strip --strip-unneeded %t.o12# RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q13 14# RUN: llvm-bolt %t.exe --relocs=1 --frame-opt=all --print-fop \15# RUN: --print-only=main --data %t.fdata -o %t.out | FileCheck %s16 17# RUN: %t.out 118 19# CHECK: BOLT-INFO: Shrink wrapping moved 1 spills inserting load/stores and 0 spills inserting push/pops20 21 .text22 .globl main23 .type main, %function24 .p2align 425main:26# FDATA: 0 [unknown] 0 1 main 0 0 51027 pushq %rbp28 movq %rsp, %rbp29 pushq %rbx # We save rbx here, but there is an30 # opportunity to move it to .LBB231 subq $0x18, %rsp32 cmpl $0x2, %edi33.J1:34 jb .BBend35# FDATA: 1 main #.J1# 1 main #.BB2# 0 1036# FDATA: 1 main #.J1# 1 main #.BBend# 0 50037.BB2:38 movq $2, %rbx # Use rbx in a cold block. Save rbx will be moved39 # just before this instruction.40 xorq %rax, %rax41 movb mystring, %al42 addq %rbx, %rax43 movb %al, mystring44 leaq mystring, %rdi45 callq puts46 lock add %r12,0x0(%rsp) # Put a lock in an unrelated instruction at the47 # dom. frontier where the restore will be moved to48 # We should not put the restore in-between the49 # lock and add! We typically avoid putting a50 # restore in the last BB instruction, but since51 # lock in llvm MC lib is considered a52 # separate instruction, we may mistakenly53 # put the restore just between these two.54 55.BBend:56 addq $0x18, %rsp57 pop %rbx # Restore should be moved58 xorq %rax, %rax59 leaveq60 retq61 .size main, .-main62 63 .data64mystring: .asciz "0 is rbx mod 10 contents in decimal\n"65