File tree Expand file tree Collapse file tree 2 files changed +65
-2
lines changed Expand file tree Collapse file tree 2 files changed +65
-2
lines changed Original file line number Diff line number Diff line change @@ -294,9 +294,19 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext &BC) {
294
294
buildNameMaps (BC);
295
295
296
296
// Preliminary assign function execution count.
297
- for (auto [YamlBF, BF] : llvm::zip_equal (YamlBP.Functions , ProfileBFs))
298
- if (BF)
297
+ for (auto [YamlBF, BF] : llvm::zip_equal (YamlBP.Functions , ProfileBFs)) {
298
+ if (!BF)
299
+ continue ;
300
+ if (!BF->hasProfile ()) {
299
301
BF->setExecutionCount (YamlBF.ExecCount );
302
+ } else {
303
+ if (opts::Verbosity >= 1 ) {
304
+ errs () << " BOLT-WARNING: dropping duplicate profile for " << YamlBF.Name
305
+ << ' \n ' ;
306
+ }
307
+ BF = nullptr ;
308
+ }
309
+ }
300
310
301
311
return Error::success ();
302
312
}
Original file line number Diff line number Diff line change
1
+ # This test ensures that a YAML profile with multiple profiles matching the same
2
+ # function is handled gracefully.
3
+
4
+ # REQUIRES: system-linux
5
+ # RUN: split-file %s %t
6
+ # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o
7
+ # RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib
8
+ # RUN: llvm-bolt %t.exe -o /dev/null --data %t/profile.yaml \
9
+ # RUN: --profile-ignore-hash -v=1 2>&1 | FileCheck %s
10
+ # CHECK: BOLT-WARNING: dropping duplicate profile for main_alias(*2)
11
+ #--- main.s
12
+ .globl main_alias
13
+ .type main_alias, %function
14
+ main_alias:
15
+ .globl main
16
+ .type main, %function
17
+ main:
18
+ .cfi_startproc
19
+ cmpl $0x0, %eax
20
+ retq
21
+ .cfi_endproc
22
+ .size main, .-main
23
+ .size main_alias, .-main_alias
24
+ #--- profile.yaml
25
+ ---
26
+ header:
27
+ profile-version: 1
28
+ binary-name: 'yaml-multiple-profiles.test.tmp.exe'
29
+ binary-build-id: '<unknown>'
30
+ profile-flags: [ lbr ]
31
+ profile-origin: branch profile reader
32
+ profile-events: ''
33
+ dfs-order: false
34
+ functions:
35
+ - name: 'main(*2)'
36
+ fid: 1
37
+ hash: 0x50BBA3441D436491
38
+ exec: 1
39
+ nblocks: 1
40
+ blocks:
41
+ - bid: 0
42
+ insns: 2
43
+ hash: 0x4D4D8FAF7D4C0000
44
+ - name: 'main_alias(*2)'
45
+ fid: 1
46
+ hash: 0x50BBA3441D436491
47
+ exec: 1
48
+ nblocks: 1
49
+ blocks:
50
+ - bid: 0
51
+ insns: 2
52
+ hash: 0x4D4D8FAF7D4C0000
53
+ ...
You can’t perform that action at this time.
0 commit comments