brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 7ad34c7 Raw
65 lines · plain
1# Test BOLT does not crash by trying to change the direction of a JRCXZ2 3# REQUIRES: system-linux4 5# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \6# RUN:   %s -o %t.o7# RUN: link_fdata %s %t.o %t.fdata8# RUN: llvm-strip --strip-unneeded %t.o9# RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q10# RUN: llvm-bolt %t.exe --relocs=1 --reorder-blocks=ext-tsp --print-finalized \11# RUN:    -o %t.out --data %t.fdata | FileCheck %s12# RUN: %t.out 1 2 313 14# CHECK: BOLT-INFO15 16  .text17  .section .text.startup,"ax",@progbits18  .p2align 5,,3119  .globl main20  .type main, %function21main:22  jmp test_function23 24.globl test_function25.hidden test_function26.type test_function,@function27.align 3228test_function:29# FDATA: 0 main 0 1 test_function 0 0 51030  xorq %rcx, %rcx31  andq $3, %rdi32  jmpq *jumptbl(,%rdi,8)33 34# Here are the 4 possible targets of the indirect branch to simulate a simple35# CFG. What is important here is that BB1, the first block, conditionally36# transfers control to the exit block with JRCXZ (.J1). We create a mock profile37# saying that this branch is taken more often than not, causing BOLT to try to38# put the exit block after it, which would require us to change the direction39# of JRCXZ.40.BB1:41  movl $0x0, %eax42.J1:43  jrcxz .BBend44# FDATA: 1 test_function #.J1# 1 test_function #.BB2# 0 1045# FDATA: 1 test_function #.J1# 1 test_function #.BBend# 0 50046.BB2:47  movl $0x2, %eax48  jmp .BBend49.Lbb3:50  movl $0x3, %eax51  jmp .BBend52.Lbb4:53  movl $0x4, %eax54.BBend:55  retq56.Lend1:57 58  .section .rodata59  .globl jumptbl60jumptbl:61  .quad .BB162  .quad .BB263  .quad .Lbb364  .quad .Lbb465