[llvm] [llvm-profgen] Fix bogus trace check (PR #225569)

Amir Ayupov via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 12:53:10 PDT 2026


================
@@ -911,6 +919,19 @@ void HybridPerfReader::parseSample(TraceStream &TraceIt, uint64_t Count) {
       if (IgnoreStackSamples) {
         Sample->CallStack.clear();
       } else {
+        NumTotalHybridSample++;
+        // Drop samples whose callchain and LBR disagree before the
+        // canonicalization below hides the disagreement.
+        uint64_t StackLeaf = Sample->CallStack.front();
+        uint64_t LBRLeaf = Sample->LBRStack[0].Target;
+        if (!isValidTrace(Binary, StackLeaf, LBRLeaf)) {
+          NumBogusTrace++;
----------------
aaupov wrote:

I don't think we need to distinguish hot/cold code if the number of bogus samples is small, as it should be, e.g. <1-2%.

If the profile has high skid pctage, I think it's best to just warn that the profile may not be accurate enough for optimization.

https://github.com/llvm/llvm-project/pull/225569


More information about the llvm-commits mailing list