1 # This reproduces a bug with shrink wrapping when moving
2 # load instructions in-between the lock prefix and another
3 # instruction (where the lock prefix applies).
5 # REQUIRES: system-linux
7 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
9 # RUN: link_fdata %s %t.o %t.fdata
10 # Delete our BB symbols so BOLT doesn't mark them as entry points
11 # RUN: llvm-strip --strip-unneeded %t.o
12 # RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q
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 %s
19 # CHECK: BOLT-INFO: Shrink wrapping moved 1 spills inserting load/stores and 0 spills inserting push/pops
26 # FDATA: 0 [unknown] 0 1 main 0 0 510
29 pushq
%rbx
# We save rbx here, but there is an
30 # opportunity to move it to .LBB2
35 # FDATA: 1 main #.J1# 1 main #.BB2# 0 10
36 # FDATA: 1 main #.J1# 1 main #.BBend# 0 500
38 movq $
2, %rbx
# Use rbx in a cold block. Save rbx will be moved
39 # just before this instruction.
46 lock
add %r12,0x0(%rsp
) # Put a lock in an unrelated instruction at the
47 # dom. frontier where the restore will be moved to
48 # We should not put the restore in-between the
49 # lock and add! We typically avoid putting a
50 # restore in the last BB instruction, but since
51 # lock in llvm MC lib is considered a
52 # separate instruction, we may mistakenly
53 # put the restore just between these two.
57 pop
%rbx
# Restore should be moved
64 mystring
: .asciz "0 is rbx mod 10 contents in decimal\n"