https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/143288
>From 6dca3b5790ee84eef5ba7455b32bb0541c970543 Mon Sep 17 00:00:00 2001 From: Amir Ayupov <aau...@fb.com> Date: Sat, 7 Jun 2025 14:53:52 -0700 Subject: [PATCH 1/2] check TraceBF Created using spr 1.3.4 --- bolt/lib/Profile/DataAggregator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index d84b341a33cdb..addff196f4f5b 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -1426,7 +1426,7 @@ void DataAggregator::parseLBRSample(const PerfBranchSample &Sample, const BinaryFunction *TraceBF = getBinaryFunctionContainingAddress(TraceFrom); FTInfo &Info = FallthroughLBRs[Trace(TraceFrom, TraceTo)]; - if (TraceBF->containsAddress(LBR.From)) + if (TraceBF && TraceBF->containsAddress(LBR.From)) ++Info.InternCount; else ++Info.ExternCount; >From 96a649ea20ab40f2440171898b2256143ece7b6b Mon Sep 17 00:00:00 2001 From: Amir Ayupov <aau...@fb.com> Date: Sat, 7 Jun 2025 20:32:26 -0700 Subject: [PATCH 2/2] sanitize external addresses Created using spr 1.3.4 --- bolt/lib/Profile/DataAggregator.cpp | 4 +++- bolt/test/X86/pre-aggregated-perf.test | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index addff196f4f5b..0e6abdb2052af 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -733,8 +733,10 @@ bool DataAggregator::doBranch(uint64_t From, uint64_t To, uint64_t Count, // corresponds to a return (if \p IsFrom) or a call continuation (otherwise). auto handleAddress = [&](uint64_t &Addr, bool IsFrom) { BinaryFunction *Func = getBinaryFunctionContainingAddress(Addr); - if (!Func) + if (!Func) { + Addr = 0; return std::pair{Func, false}; + } Addr -= Func->getAddress(); diff --git a/bolt/test/X86/pre-aggregated-perf.test b/bolt/test/X86/pre-aggregated-perf.test index 92e093c238e00..cc79cbd339505 100644 --- a/bolt/test/X86/pre-aggregated-perf.test +++ b/bolt/test/X86/pre-aggregated-perf.test @@ -67,10 +67,10 @@ BASIC-ERROR: BOLT-INFO: 0 out of 7 functions in the binary (0.0%) have non-empty BASIC-SUCCESS: BOLT-INFO: 4 out of 7 functions in the binary (57.1%) have non-empty execution profile CHECK-BASIC-NL: no_lbr cycles -PERF2BOLT: 0 [unknown] 7f36d18d60c0 1 main 53c 0 2 +PERF2BOLT: 0 [unknown] 0 1 main 53c 0 2 PERF2BOLT: 1 main 451 1 SolveCubic 0 0 2 -PERF2BOLT: 1 main 490 0 [unknown] 4005f0 0 1 -PERF2BOLT: 1 main 537 0 [unknown] 400610 0 1 +PERF2BOLT: 1 main 490 0 [unknown] 0 0 1 +PERF2BOLT: 1 main 537 0 [unknown] 0 0 1 PERF2BOLT: 1 usqrt 30 1 usqrt 32 0 22 PERF2BOLT: 1 usqrt 30 1 usqrt 39 4 33 PERF2BOLT: 1 usqrt 35 1 usqrt 39 0 22 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits