Skip to content

Commit d3d5ddb

Browse files
aaupovrorth
authored andcommitted
[BOLT] Zero initialize pre-aggregated counters (llvm#142698)
llvm#140196 introduced UB by using uninitialized misprediction count for pre-aggregated traces. Fix by zero initializing both counters. Test Plan: updated entry-point-fallthru.s
1 parent db573a6 commit d3d5ddb

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
12201220
// Storage for parsed fields.
12211221
StringRef EventName;
12221222
std::optional<Location> Addr[3];
1223-
int64_t Counters[2];
1223+
int64_t Counters[2] = {0};
12241224

12251225
while (Type == INVALID || Type == EVENT_NAME) {
12261226
while (checkAndConsumeFS()) {

bolt/test/X86/entry-point-fallthru.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
# RUN: link_fdata %s %t %t.preagg PREAGG
77
# RUN: perf2bolt %t -p %t.preagg --pa -o %t.fdata | FileCheck %s
88
# CHECK: traces mismatching disassembled function contents: 0
9+
# RUN: FileCheck %s --check-prefix=CHECK-FDATA --input-file %t.fdata
10+
# CHECK-FDATA: 1 main 0 1 main 6 0 1
11+
# CHECK-FDATA-NEXT: 1 main e 1 main 11 0 1
12+
# CHECK-FDATA-NEXT: 1 main 11 1 main 0 0 1
913

1014
.globl main
1115
main:

0 commit comments

Comments
 (0)