aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmir Ayupov <aaupov@fb.com>2025-06-03 20:50:19 -0700
committerGitHub <noreply@github.com>2025-06-03 20:50:19 -0700
commitdc513fa8dc361cb71a2c607f2bd75d812f31459b (patch)
tree5f2db0b801156f7ba3b75d4f9326fd41ad5b0a86
parent88738a74f05ba4002f38b8bdeebd944762c8ae7b (diff)
downloadllvm-dc513fa8dc361cb71a2c607f2bd75d812f31459b.zip
llvm-dc513fa8dc361cb71a2c607f2bd75d812f31459b.tar.gz
llvm-dc513fa8dc361cb71a2c607f2bd75d812f31459b.tar.bz2
[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
-rw-r--r--bolt/lib/Profile/DataAggregator.cpp2
-rw-r--r--bolt/test/X86/entry-point-fallthru.s4
2 files changed, 5 insertions, 1 deletions
diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp
index 2527b5b..f05c40e 100644
--- a/bolt/lib/Profile/DataAggregator.cpp
+++ b/bolt/lib/Profile/DataAggregator.cpp
@@ -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()) {
diff --git a/bolt/test/X86/entry-point-fallthru.s b/bolt/test/X86/entry-point-fallthru.s
index edf1424..850247b 100644
--- a/bolt/test/X86/entry-point-fallthru.s
+++ b/bolt/test/X86/entry-point-fallthru.s
@@ -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: