File: tail-duplication-complex.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (60 lines) | stat: -rw-r--r-- 1,524 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# REQUIRES: system-linux

# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
# RUN:   %s -o %t.o
# RUN: link_fdata %s %t.o %t.fdata
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q

# RUN: llvm-bolt %t.exe --data %t.fdata --print-finalized \
# RUN:    --tail-duplication=moderate --tail-duplication-minimum-offset=1 \
# RUN:    -o %t.out | FileCheck %s

# FDATA: 1 main f 1 main 19 0 10
# FDATA: 1 main f 1 main 11 0 13
# FDATA: 1 main 17 1 main 3c 0 10
# FDATA: 1 main 39 1 main 3c 0 10

# CHECK: tail duplication modified 1 ({{.*}}%) functions; duplicated 1 blocks ({{.*}} bytes) responsible for {{.*}} dynamic executions ({{.*}} of all block executions)
# CHECK: BB Layout   : .LBB00, .Ltmp0, .Ltail-dup0, .Ltmp1, .Ltmp2

# This is the C++ code fed to Clang
# int fib(int term) {
#   if (term <= 1)
#     return term;
#   return fib(term-1) + fib(term-2);
# }

    .text
    .globl main
    .type main, %function
    .size main, .Lend-main
main:
    push   %rbp
    mov    %rsp,%rbp
    sub    $0x10,%rsp
    mov    %edi,-0x8(%rbp)
    cmpl   $0x1,-0x8(%rbp)
    jg     .BB1
.BB0:
    mov    -0x8(%rbp),%eax
    mov    %eax,-0x4(%rbp)
    jmp   .BB2
.BB1:
    mov    -0x8(%rbp),%edi
    sub    $0x1,%edi
    call   main
    mov    %eax,-0xc(%rbp)
    mov    -0x8(%rbp),%edi
    sub    $0x2,%edi
    call   main
    mov    %eax,%ecx
    mov    -0xc(%rbp),%eax
    add    %ecx,%eax
    mov    %eax,-0x4(%rbp)
.BB2:
    mov    -0x4(%rbp),%eax
    add    $0x10,%rsp
    pop    %rbp
    retq
    nopl   0x0(%rax)
.Lend: