Skip to content

Commit 0b7c95f

Browse files
aaupovtomtor
authored andcommitted
[BOLT] Sort EntryData (llvm#143308)
Aggregated branch data has two containers: `Data` for local branches, and `EntryData` for external branches. Fix the omission and sort `EntryData` to ensure stable output fdata profiles. Test Plan: updated pre-aggregated-perf.test
1 parent 0674b1c commit 0b7c95f

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,10 @@ void DataAggregator::processProfile(BinaryContext &BC) {
580580
}
581581
}
582582

583-
for (auto &FuncBranches : NamesToBranches)
583+
for (auto &FuncBranches : NamesToBranches) {
584584
llvm::stable_sort(FuncBranches.second.Data);
585+
llvm::stable_sort(FuncBranches.second.EntryData);
586+
}
585587

586588
for (auto &MemEvents : NamesToMemEvents)
587589
llvm::stable_sort(MemEvents.second.Data);

bolt/test/X86/pre-aggregated-perf.test

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,26 @@ RUN: llvm-bolt %t.exe -p %p/Inputs/pre-aggregated.txt --pa -o %t.null | FileChec
3636

3737
CHECK: BOLT-INFO: 4 out of 7 functions in the binary (57.1%) have non-empty execution profile
3838

39-
RUN: cat %t | sort | FileCheck %s -check-prefix=PERF2BOLT
40-
RUN: cat %t.new | FileCheck %s -check-prefix=NEWFORMAT
39+
RUN: FileCheck %s -check-prefix=PERF2BOLT --input-file %t
40+
RUN: FileCheck %s -check-prefix=NEWFORMAT --input-file %t.new
4141

4242
## Test --profile-format option with perf2bolt
4343
RUN: perf2bolt %t.exe -o %t.fdata --pa -p %p/Inputs/pre-aggregated.txt \
4444
RUN: --profile-format=fdata
45-
RUN: cat %t.fdata | sort | FileCheck %s -check-prefix=PERF2BOLT
45+
RUN: FileCheck %s -check-prefix=PERF2BOLT --input-file %t.fdata
4646

4747
RUN: perf2bolt %t.exe -o %t.yaml --pa -p %p/Inputs/pre-aggregated.txt \
4848
RUN: --profile-format=yaml --profile-use-dfs
49-
RUN: cat %t.yaml | FileCheck %s -check-prefix=NEWFORMAT
49+
RUN: FileCheck %s -check-prefix=NEWFORMAT --input-file %t.yaml
5050

5151
## Test --profile-format option with llvm-bolt --aggregate-only
5252
RUN: llvm-bolt %t.exe -o %t.bolt.fdata --pa -p %p/Inputs/pre-aggregated.txt \
5353
RUN: --aggregate-only --profile-format=fdata
54-
RUN: cat %t.bolt.fdata | sort | FileCheck %s -check-prefix=PERF2BOLT
54+
RUN: FileCheck %s -check-prefix=PERF2BOLT --input-file %t.bolt.fdata
5555

5656
RUN: llvm-bolt %t.exe -o %t.bolt.yaml --pa -p %p/Inputs/pre-aggregated.txt \
5757
RUN: --aggregate-only --profile-format=yaml --profile-use-dfs
58-
RUN: cat %t.bolt.yaml | FileCheck %s -check-prefix=NEWFORMAT
58+
RUN: FileCheck %s -check-prefix=NEWFORMAT --input-file %t.bolt.yaml
5959

6060
## Test pre-aggregated basic profile
6161
RUN: perf2bolt %t.exe -o %t --pa -p %p/Inputs/pre-aggregated-basic.txt -o %t.ba \
@@ -67,16 +67,17 @@ BASIC-ERROR: BOLT-INFO: 0 out of 7 functions in the binary (0.0%) have non-empty
6767
BASIC-SUCCESS: BOLT-INFO: 4 out of 7 functions in the binary (57.1%) have non-empty execution profile
6868
CHECK-BASIC-NL: no_lbr cycles
6969

70-
PERF2BOLT: 0 [unknown] 7f36d18d60c0 1 main 53c 0 2
71-
PERF2BOLT: 1 main 451 1 SolveCubic 0 0 2
72-
PERF2BOLT: 1 main 490 0 [unknown] 4005f0 0 1
73-
PERF2BOLT: 1 main 537 0 [unknown] 400610 0 1
74-
PERF2BOLT: 1 usqrt 30 1 usqrt 32 0 22
75-
PERF2BOLT: 1 usqrt 30 1 usqrt 39 4 33
76-
PERF2BOLT: 1 usqrt 35 1 usqrt 39 0 22
77-
PERF2BOLT: 1 usqrt 3d 1 usqrt 10 0 58
78-
PERF2BOLT: 1 usqrt 3d 1 usqrt 3f 0 22
79-
PERF2BOLT: 1 usqrt a 1 usqrt 10 0 22
70+
PERF2BOLT: 1 frame_dummy/1 1e 1 frame_dummy/1 0 0 1
71+
PERF2BOLT-NEXT: 1 main 451 1 SolveCubic 0 0 2
72+
PERF2BOLT-NEXT: 1 main 490 0 [unknown] 4005f0 0 1
73+
PERF2BOLT-NEXT: 1 main 537 0 [unknown] 400610 0 1
74+
PERF2BOLT-NEXT: 0 [unknown] 7f36d18d60c0 1 main 53c 0 2
75+
PERF2BOLT-NEXT: 1 usqrt a 1 usqrt 10 0 22
76+
PERF2BOLT-NEXT: 1 usqrt 30 1 usqrt 32 0 22
77+
PERF2BOLT-NEXT: 1 usqrt 30 1 usqrt 39 4 33
78+
PERF2BOLT-NEXT: 1 usqrt 35 1 usqrt 39 0 22
79+
PERF2BOLT-NEXT: 1 usqrt 3d 1 usqrt 10 0 58
80+
PERF2BOLT-NEXT: 1 usqrt 3d 1 usqrt 3f 0 22
8081

8182
NEWFORMAT: - name: 'frame_dummy/1'
8283
NEWFORMAT: fid: 3

0 commit comments

Comments
 (0)