brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 1a96f12 Raw
67 lines · plain
1## This checks that we don't create an invalid CFG when there is an2## unreachable direct jump right after an indirect one.3 4# REQUIRES: system-linux5 6# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \7# RUN:   %s -o %t.o8# RUN: link_fdata %s %t.o %t.fdata9# RUN: llvm-strip --strip-unneeded %t.o10# RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q -nostdlib11# RUN: llvm-bolt %t.exe -o %t.out --data %t.fdata \12# RUN:     --eliminate-unreachable --print-cfg | FileCheck %s13 14  .globl _start15  .type _start, %function16_start:17  .cfi_startproc18# FDATA: 0 [unknown] 0 1 _start 0 0 119  push  %rbp20  mov   %rsp, %rbp21  push  %rbx22  push  %r1423  subq  $0x20, %rsp24  movq  %rdi, %rcx25b:26  jmpq  *JUMP_TABLE(,%rcx,8)27# FDATA: 1 _start #b# 1 _start #hotpath# 0 2028## Unreachable direct jump here. Our CFG should still make sense and properly29## place this instruction in a new basic block.30  jmp  .lbb231.lbb1:  je  .lexit32.lbb2:33  xorq  %rax, %rax34  addq  $0x20, %rsp35  pop %r1436  pop %rbx37  pop %rbp38  ret39hotpath:40  movq  $2, %rax41  addq  $0x20, %rsp42  pop %r1443  pop %rbx44  pop %rbp45  ret46.lexit:47  movq  $1, %rax48  addq  $0x20, %rsp49  pop %r1450  pop %rbx51  pop %rbp52  ret53  .cfi_endproc54  .size _start, .-_start55 56  .rodata57  .globl JUMP_TABLE58JUMP_TABLE:59  .quad .lbb160  .quad .lbb261  .quad hotpath62 63## No basic blocks above should have 4 successors! That is a bug.64# CHECK-NOT:   Successors: {{.*}} (mispreds: 0, count: 20), {{.*}} (mispreds: 0, count: 0), {{.*}} (mispreds: 0, count: 0), {{.*}} (mispreds: 0, count: 0)65# Check successful removal of stray direct jmp66#  CHECK:  UCE removed 1 block67