1## Tests blocks matching by called function names in inferStaleProfile. 2 3# REQUIRES: system-linux, asserts 4# RUN: split-file %s %t 5# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o 6# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib 7# RUN: llvm-bolt %t.exe -o %t.out --data %t/yaml --profile-ignore-hash -v=1 \ 8# RUN: --dyno-stats --print-cfg --infer-stale-profile=1 --debug-only=bolt-prof \ 9# RUN: 2>&1 | FileCheck %s 10 11# CHECK: BOLT-INFO: applying profile inference for "qux" 12# CHECK: Matched yaml block (bid = 1) with hash 4 to BB (index = 0) with hash 314e1bc10000 13# CHECK: call match 14 15# CHECK: BOLT-INFO: applying profile inference for "fred" 16# CHECK: Matched yaml block (bid = 1) with hash 5 to BB (index = 0) with hash 7541bc10000 17# CHECK: call match 18 19#--- main.s 20.globl foo # -- Begin function foo 21 .p2align 4, 0x90 22 .type foo,@function 23foo: # @foo 24# %bb.0: 25 pushq %rbp 26 movq %rsp, %rbp 27 popq %rbp 28 retq 29.Lfunc_end0: 30 .size foo, .Lfunc_end0-foo 31 # -- End function 32 .globl bar # -- Begin function bar 33 .p2align 4, 0x90 34 .type bar,@function 35bar: # @bar 36# %bb.0: 37 pushq %rbp 38 movq %rsp, %rbp 39 popq %rbp 40 retq 41.Lfunc_end1: 42 .size bar, .Lfunc_end1-bar 43 # -- End function 44 .globl qux # -- Begin function qux 45 .p2align 4, 0x90 46 .type qux,@function 47qux: # @qux 48# %bb.0: 49 pushq %rbp 50 movq %rsp, %rbp 51 callq foo 52 callq bar 53 popq %rbp 54 retq 55.Lfunc_end2: 56 .size qux, .Lfunc_end2-qux 57 # -- End function 58 .globl fred # -- Begin function fred 59 .p2align 4, 0x90 60 .type fred,@function 61fred: # @fred 62# %bb.0: 63 pushq %rbp 64 movq %rsp, %rbp 65 callq foo 66 callq qux 67 callq bar 68 callq bar 69 callq foo 70 popq %rbp 71 retq 72.Lfunc_end3: 73 .size fred, .Lfunc_end3-fred 74 # -- End function 75 .globl main # -- Begin function main 76 .p2align 4, 0x90 77 .type main,@function 78main: # @main 79# %bb.0: 80 pushq %rbp 81 movq %rsp, %rbp 82 xorl %eax, %eax 83 popq %rbp 84 retq 85.Lfunc_end4: 86 .size main, .Lfunc_end4-main 87 # -- End function 88 .addrsig 89 .addrsig_sym foo 90 .addrsig_sym bar 91 .addrsig_sym qux 92 93#--- yaml 94--- 95header: 96 profile-version: 1 97 binary-name: 'match-functions-with-calls-as-anchors.s.tmp.exe' 98 binary-build-id: '<unknown>' 99 profile-flags: [ lbr ] 100 profile-origin: branch profile reader 101 profile-events: '' 102 dfs-order: false 103 hash-func: xxh3 104functions: 105 - name: main 106 fid: 0 107 hash: 0x0000000000000001 108 exec: 1 109 nblocks: 6 110 blocks: 111 - bid: 1 112 hash: 0x0000000000000001 113 insns: 1 114 succ: [ { bid: 3, cnt: 1} ] 115 - name: foo 116 fid: 1 117 hash: 0x0000000000000002 118 exec: 1 119 nblocks: 6 120 blocks: 121 - bid: 1 122 hash: 0x0000000000000002 123 insns: 1 124 succ: [ { bid: 3, cnt: 1} ] 125 126 - name: bar 127 fid: 2 128 hash: 0x0000000000000003 129 exec: 1 130 nblocks: 6 131 blocks: 132 - bid: 1 133 hash: 0x0000000000000003 134 insns: 1 135 succ: [ { bid: 3, cnt: 1} ] 136 - name: qux 137 fid: 3 138 hash: 0x0000000000000004 139 exec: 4 140 nblocks: 6 141 blocks: 142 - bid: 1 143 hash: 0x0000000000000004 144 insns: 1 145 succ: [ { bid: 3, cnt: 1} ] 146 calls: [ { off : 0, fid : 1, cnt : 0}, 147 { off : 0, fid : 2, cnt : 0} ] 148 - name: fred 149 fid: 4 150 hash: 0x0000000000000005 151 exec: 1 152 nblocks: 6 153 blocks: 154 - bid: 1 155 hash: 0x0000000000000005 156 insns: 1 157 succ: [ { bid: 3, cnt: 1} ] 158 calls: [ { off : 0, fid : 3, cnt : 0}, 159 { off : 0, fid : 1, cnt : 0}, 160 { off : 0, fid : 2, cnt : 0}, 161 { off : 0, fid : 1, cnt : 0}, 162 { off : 0, fid : 2, cnt : 0} ] 163... 164