aboutsummaryrefslogtreecommitdiff
path: root/bolt/test/X86/match-functions-with-calls-as-anchors.test
blob: 7fef128453a0752837168688b3b848c280056b64 (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
## Tests blocks matching by called function names in inferStaleProfile.

# REQUIRES: system-linux
# RUN: split-file %s %t
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib
# RUN: llvm-bolt %t.exe -o %t.out --data %t/yaml --profile-ignore-hash -v=1 \
# RUN:   --dyno-stats --print-cfg --infer-stale-profile=1 --debug 2>&1 | FileCheck %s

# CHECK: BOLT-INFO: applying profile inference for "qux"
# CHECK: Matched yaml block (bid = 1) with hash 4 to BB (index = 0) with hash 314e1bc10000
# CHECK:  loose match

# CHECK: BOLT-INFO: applying profile inference for "fred"
# CHECK: Matched yaml block (bid = 1) with hash 5 to BB (index = 0) with hash 7541bc10000
# CHECK:  loose match

#--- main.s
.globl  foo                         # -- Begin function foo
  .p2align        4, 0x90
  .type   foo,@function
foo:                                # @foo
# %bb.0:
  pushq   %rbp
  movq    %rsp, %rbp
  popq    %rbp
  retq
.Lfunc_end0:
  .size   foo, .Lfunc_end0-foo
                                      # -- End function
  .globl  bar                         # -- Begin function bar
  .p2align        4, 0x90
  .type   bar,@function
bar:                                # @bar
# %bb.0:
  pushq   %rbp
  movq    %rsp, %rbp
  popq    %rbp
  retq
.Lfunc_end1:
  .size   bar, .Lfunc_end1-bar
                                      # -- End function
  .globl  qux                         # -- Begin function qux
  .p2align        4, 0x90
  .type   qux,@function
qux:                                # @qux
# %bb.0:
  pushq   %rbp
  movq    %rsp, %rbp
  callq   foo
  callq   bar
  popq    %rbp
  retq
.Lfunc_end2:
  .size   qux, .Lfunc_end2-qux
                                      # -- End function
  .globl  fred                        # -- Begin function fred
  .p2align        4, 0x90
  .type   fred,@function
fred:                               # @fred
# %bb.0:
  pushq   %rbp
  movq    %rsp, %rbp
  callq   foo
  callq   qux
  callq   bar
  callq   bar
  callq   foo
  popq    %rbp
  retq
.Lfunc_end3:
  .size   fred, .Lfunc_end3-fred
                                          # -- End function
  .globl  main                            # -- Begin function main
  .p2align        4, 0x90
  .type   main,@function
main:                                   # @main
# %bb.0:
  pushq   %rbp
  movq    %rsp, %rbp
  xorl    %eax, %eax
  popq    %rbp
  retq
.Lfunc_end4:
  .size   main, .Lfunc_end4-main
                                  # -- End function
  .addrsig
  .addrsig_sym foo
  .addrsig_sym bar
  .addrsig_sym qux

#--- yaml
---
header:
  profile-version: 1
  binary-name:     'match-functions-with-calls-as-anchors.s.tmp.exe'
  binary-build-id: '<unknown>'
  profile-flags:   [ lbr ]
  profile-origin:  branch profile reader
  profile-events:  ''
  dfs-order:       false
  hash-func:       xxh3
functions:
  - name:            main
    fid:             0
    hash:            0x0000000000000001
    exec:            1
    nblocks:         6
    blocks:
      - bid:             1
        hash:            0x0000000000000001
        insns:           1
        succ:            [ { bid: 3, cnt: 1} ]
  - name:            foo
    fid:             1
    hash:            0x0000000000000002
    exec:            1
    nblocks:         6
    blocks:
      - bid:             1
        hash:            0x0000000000000002
        insns:           1
        succ:            [ { bid: 3, cnt: 1} ]

  - name:            bar
    fid:             2
    hash:            0x0000000000000003
    exec:            1
    nblocks:         6
    blocks:
      - bid:             1
        hash:            0x0000000000000003
        insns:           1
        succ:            [ { bid: 3, cnt: 1} ]
  - name:            qux
    fid:             3
    hash:            0x0000000000000004
    exec:            4
    nblocks:         6
    blocks:
      - bid:             1
        hash:            0x0000000000000004
        insns:           1
        succ:            [ { bid: 3, cnt: 1} ]
        calls:           [ { off : 0, fid : 1, cnt : 0},
                           { off : 0, fid : 2, cnt : 0} ]
  - name:            fred
    fid:             4
    hash:            0x0000000000000005
    exec:            1
    nblocks:         6
    blocks:
      - bid:             1
        hash:            0x0000000000000005
        insns:           1
        succ:            [ { bid: 3, cnt: 1} ]
        calls:           [ { off : 0, fid : 3, cnt : 0},
                           { off : 0, fid : 1, cnt : 0},
                           { off : 0, fid : 2, cnt : 0},
                           { off : 0, fid : 1, cnt : 0},
                           { off : 0, fid : 2, cnt : 0} ]
...