[BOLT] Zero initialize pre-aggregated counters (#142698)

#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
This commit is contained in:
Amir Ayupov
2025-06-03 20:50:19 -07:00
committed by GitHub
parent 88738a74f0
commit dc513fa8dc
2 changed files with 5 additions and 1 deletions

View File

@@ -1220,7 +1220,7 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
// Storage for parsed fields.
StringRef EventName;
std::optional<Location> Addr[3];
int64_t Counters[2];
int64_t Counters[2] = {0};
while (Type == INVALID || Type == EVENT_NAME) {
while (checkAndConsumeFS()) {

View File

@@ -6,6 +6,10 @@
# RUN: link_fdata %s %t %t.preagg PREAGG
# RUN: perf2bolt %t -p %t.preagg --pa -o %t.fdata | FileCheck %s
# CHECK: traces mismatching disassembled function contents: 0
# RUN: FileCheck %s --check-prefix=CHECK-FDATA --input-file %t.fdata
# CHECK-FDATA: 1 main 0 1 main 6 0 1
# CHECK-FDATA-NEXT: 1 main e 1 main 11 0 1
# CHECK-FDATA-NEXT: 1 main 11 1 main 0 0 1
.globl main
main: