brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · fc8e3ce Raw
61 lines · plain
1# This reproduces a bug with shrink wrapping when trying to move2# push-pops where restores were not validated to be POPs (and could be3# a regular load, which violated our assumptions). Check that we4# identify those cases.5 6# REQUIRES: system-linux7 8# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \9# RUN:   %s -o %t.o10# RUN: link_fdata %s %t.o %t.fdata11# Delete our BB symbols so BOLT doesn't mark them as entry points12# RUN: llvm-strip --strip-unneeded %t.o13# RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q14 15# RUN: llvm-bolt %t.exe --relocs=1 --frame-opt=all --print-finalized \16# RUN:    --print-only=main --data %t.fdata -o %t.out | FileCheck %s17 18# RUN: %t.out19 20# CHECK: BOLT-INFO: Shrink wrapping moved 1 spills inserting load/stores and 0 spills inserting push/pops21 22  .text23  .globl  main24  .type main, %function25  .p2align  426main:27# FDATA: 0 [unknown] 0 1 main 0 0 51028  pushq %rbp29  movq  %rsp, %rbp30  pushq %rbx                  # We save rbx here, but there is an31                              # opportunity to move it to .LBB232  subq  $0x18, %rsp33  cmpl  $0x2, %edi34.J1:35  jb    .BBend36# FDATA: 1 main #.J1# 1 main #.BB2# 0 1037# FDATA: 1 main #.J1# 1 main #.BBend# 0 50038.BB2:39  movq $2, %rbx               # Use rbx in a cold block40  xorq %rax, %rax41  movb mystring, %al42  addq %rbx, %rax43  movb %al, mystring44  leaq mystring, %rdi45# Avoid making the actual call here to allow push-pop mode to operate46# without fear of an unknown function that may require aligned stack47#  callq puts48 49.BBend:50  mov -0x08(%rbp), %rbx       # Original restore is here. Instead of a pop51                              # we use a load to reproduce gcc behavior while52                              # using leave in epilogue. Ordinarily it would53                              # addq $0x18, %rsp followed by pop %rbx54  xorq %rax, %rax55  leaveq56  retq57  .size main, .-main58 59  .data60mystring: .asciz "0 is rbx mod 10 contents in decimal\n"61