xref: /llvm-project/bolt/test/X86/bb-with-two-tail-calls.s (revision 11791ae7b0b05b8bd8d806331ff51da618912cf8)
1## This reproduces a bug with dynostats when trying to compute branch stats
2## at a block with two tails calls (one conditional and one unconditional).
3
4# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
5# RUN:   %s -o %t.o
6# RUN: link_fdata %s %t.o %t.fdata
7# RUN: llvm-strip --strip-unneeded %t.o
8# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib
9# RUN: llvm-bolt %t.exe -o %t.out --data %t.fdata --lite=0 --dyno-stats \
10# RUN:    --print-sctc --print-only=_start -enable-bat 2>&1 | FileCheck %s
11# RUN: llvm-objdump --syms %t.out > %t.log
12# RUN: llvm-bat-dump %t.out --dump-all >> %t.log
13# RUN: FileCheck %s --input-file %t.log --check-prefix=CHECK-BAT
14
15# CHECK-NOT: Assertion `BranchInfo.size() == 2 && "could only be called for blocks with 2 successors"' failed.
16# Two tail calls in the same basic block after SCTC:
17# CHECK:         {{.*}}:   ja      {{.*}} # TAILCALL # Offset: 7 # CTCTakenCount: 4
18# CHECK-NEXT:    {{.*}}:   jmp     {{.*}} # TAILCALL # Offset: 13
19
20## Confirm that a deleted basic block is emitted at function end offset (0xe)
21# CHECK-BAT: [[#%x,ADDR:]] g .text  [[#%x,SIZE:]] _start
22# CHECK-BAT: Function Address: 0x[[#%x,ADDR]]
23# CHECK-BAT: 0x[[#%x,SIZE]]
24# CHECK-BAT: NumBlocks: 5
25
26  .globl _start
27_start:
28    je x
29a:  ja b
30    jmp c
31x:  ret
32# FDATA: 1 _start #a# 1 _start #b# 2 4
33b:  jmp e
34c:
35    .nops 1
36    jmp f
37
38  .globl e
39e:
40    nop
41
42  .globl f
43f:
44    nop
45