xref: /llvm-project/bolt/test/X86/issue26.s (revision 11791ae7b0b05b8bd8d806331ff51da618912cf8)
1## This reproduces issue 26 from our github repo
2##  BOLT fails with the following assertion:
3##    llvm/tools/llvm-bolt/src/BinaryFunction.cpp:2950: void llvm::bolt::BinaryFunction::postProcessBranches(): Assertion `validateCFG() && "invalid CFG"' failed.
4
5# REQUIRES: system-linux
6
7# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
8# RUN:   %s -o %t.o
9# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
10# RUN: llvm-bolt %t.exe --relocs --print-cfg -o %t.out 2>&1 \
11# RUN:    | FileCheck %s
12
13# CHECK-NOT: BOLT-WARNING: CFG invalid in XYZ @ .LBB0
14
15# CHECK: Binary Function "XYZ"
16
17# CHECK: .Ltmp{{.*}} (1 instructions, align : 1)
18# CHECK-NEXT: Secondary Entry Point: FUNCat{{.*}}
19
20  .text
21  .globl XYZ
22  .type XYZ, %function
23  .size XYZ, .Lend1-XYZ
24XYZ:
25  movl %fs:-0x350, %eax
26  cmpl %eax, %edi
27  jne .L1
28
29  cmp %rdx, (%rsi)
30  jne .L2
31
32  movq %rcx, (%rsi)
33.L1:
34  retq
35
36.L2:
37  movl $0xffffffff, %eax
38  retq
39.Lend1:
40
41  .globl FUNC
42  .type FUNC, %function
43  .size FUNC, .Lend - FUNC
44FUNC:
45  cmpq %rdi, %rsi
46  je .L1
47  retq
48.Lend:
49
50  .globl main
51  .type main, %function
52  .size main, .Lend2 - main
53main:
54  xorq %rax, %rax
55  retq
56
57# For relocations against .text
58  call exit
59.Lend2:
60