brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 1a16b40 Raw
89 lines · plain
1# This reproduces a bug with shrink wrapping when trying to move2# push-pops in a function where we are not allowed to modify the3# stack layout for alignment reasons. In this bug, we failed to4# propagate alignment requirement upwards in the call graph for5# some functions when there is a cycle in the call graph.6 7# REQUIRES: system-linux8 9# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \10# RUN:   %s -o %t.o11# RUN: link_fdata %s %t.o %t.fdata12# Delete our BB symbols so BOLT doesn't mark them as entry points13# RUN: llvm-strip --strip-unneeded %t.o14# RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q15 16# RUN: llvm-bolt %t.exe --relocs=1 --frame-opt=all --print-finalized \17# RUN:   --lite=0 --print-only=main --data %t.fdata -o %t.out | FileCheck %s18 19# RUN: %t.out20 21# CHECK: BOLT-INFO: Shrink wrapping moved 1 spills inserting load/stores and 0 spills inserting push/pops22 23  .text24  .globl bar25  .type bar, %function26  .p2align 427bar:28# FDATA: 0 [unknown] 0 1 bar 0 0 51029  pushq %rbp30  movq  %rsp, %rbp31  pushq %rbx                  # We save rbx here, but there is an32                              # opportunity to move it to .BB233  subq  $0x18, %rsp34  cmpl  $0x2, %edi35.J1:36  jb    .BBend37# FDATA: 1 bar #.J1# 1 bar #.BB2# 0 1038# FDATA: 1 bar #.J1# 1 bar #.BBend# 0 50039.BB2:40  movq $2, %rbx               # Use rbx in a cold block41  xorq %rax, %rax42  movb mystring, %al43  addq %rbx, %rax44  movb %al, mystring45  leaq mystring, %rdi46  #callq puts47 48.BBend:49  addq $0x18, %rsp50  pop %rbx                    # Restore51  xorq %rax, %rax52  cmpq  $0x0, %rax53  jne  .BBnever54  jmp  .BBbarend55.BBnever:56  # This is a path that is never executed, but we add a call to main here57  # to force a cycle in the call graph and to require us to have an aligned58  # stack59  callq main60.BBbarend:61  leaveq62  retq63  .size bar, .-bar64 65# Frame alignedness information needs to be transmitted from foo to main to bar66  .globl  main67  .type main, %function68  .p2align  469main:70  # Call a function that requires an aligned stack71  callq foo72  # Call a function that can be shrink-wrapped73  callq bar74  retq75  .size main, .-main76 77# Frame alignedness information needs to be transmitted from foo to main to bar78  .globl  foo79  .type foo, %function80  .p2align  481foo:82  # Use an instruction that requires an aligned stack83  movdqa -0x10(%rsp), %xmm084  retq85  .size foo, .-foo86 87  .data88mystring: .asciz "0 is rbx mod 10 contents in decimal\n"89