diff --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h --- a/llvm/include/llvm/ProfileData/SampleProf.h +++ b/llvm/include/llvm/ProfileData/SampleProf.h @@ -583,11 +583,6 @@ uint32_t Discriminator) const { const auto &ret = BodySamples.find(LineLocation(LineOffset, Discriminator)); if (ret == BodySamples.end()) { - // For CSSPGO, in order to conserve profile size, we no longer write out - // locations profile for those not hit during training, so we need to - // treat them as zero instead of error here. - if (FunctionSamples::ProfileIsCS || FunctionSamples::ProfileIsProbeBased) - return 0; return std::error_code(); } else { // Return error for an invalid sample count which is usually assigned to diff --git a/llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-inline.prof b/llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-inline.prof --- a/llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-inline.prof +++ b/llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-inline.prof @@ -6,6 +6,9 @@ 1: 23 2: 382920 3: 382915 + 4: 0 + 5: 0 + 6: 0 !CFGChecksum: 138828622701 [bar]:23:23 1: 23 @@ -15,4 +18,7 @@ 1: 23 2: 382920 3: 382915 + 4: 0 + 5: 0 + 6: 0 !CFGChecksum: 138828622701 \ No newline at end of file diff --git a/llvm/test/tools/llvm-profgen/fname-canonicalization.test b/llvm/test/tools/llvm-profgen/fname-canonicalization.test --- a/llvm/test/tools/llvm-profgen/fname-canonicalization.test +++ b/llvm/test/tools/llvm-profgen/fname-canonicalization.test @@ -22,8 +22,6 @@ ; CHECK-PROBE-FNAME: !CFGChecksum: 563088904013236 ; CHECK-PROBE-FNAME:[main:2 @ foo:8 @ _ZL3barii.__uniq.26267048767521081047744692097241227776]:30:15 ; CHECK-PROBE-FNAME: 1: 15 -; CHECK-PROBE-FNAME: 2: 18446744073709551615 -; CHECK-PROBE-FNAME: 3: 18446744073709551615 ; CHECK-PROBE-FNAME: 4: 15 ; CHECK-PROBE-FNAME: !CFGChecksum: 72617220756 diff --git a/llvm/test/tools/llvm-profgen/inline-cs-dangling-pseudoprobe.test b/llvm/test/tools/llvm-profgen/inline-cs-dangling-pseudoprobe.test --- a/llvm/test/tools/llvm-profgen/inline-cs-dangling-pseudoprobe.test +++ b/llvm/test/tools/llvm-profgen/inline-cs-dangling-pseudoprobe.test @@ -2,14 +2,17 @@ ; RUN: FileCheck %s --input-file %t ; CHECK: [main:2 @ foo]:58:0 +; CHECK-NEXT: 1: 0 ; CHECK-NEXT: 2: 15 ; CHECK-NEXT: 3: 14 +; CHECK-NEXT: 4: 0 ; CHECK-NEXT: 5: 14 ; CHECK-NEXT: 6: 15 +; CHECK-NEXT: 7: 0 +; CHECK-NEXT: 9: 0 ; CHECK-NEXT: !CFGChecksum: 138950591924 ; CHECK:[main:2 @ foo:8 @ bar]:1:0 -; CHECK-NEXT: 2: 18446744073709551615 -; CHECK-NEXT: 3: 18446744073709551615 +; CHECK-NEXT: 1: 0 ; CHECK-NEXT: 4: 1 ; CHECK-NEXT: !CFGChecksum: 72617220756 diff --git a/llvm/test/tools/llvm-profgen/inline-cs-pseudoprobe.test b/llvm/test/tools/llvm-profgen/inline-cs-pseudoprobe.test --- a/llvm/test/tools/llvm-profgen/inline-cs-pseudoprobe.test +++ b/llvm/test/tools/llvm-profgen/inline-cs-pseudoprobe.test @@ -2,17 +2,18 @@ ; RUN: FileCheck %s --input-file %t ; CHECK: [main:2 @ foo]:74:0 +; CHECK-NEXT: 1: 0 ; CHECK-NEXT: 2: 15 ; CHECK-NEXT: 3: 15 ; CHECK-NEXT: 4: 14 ; CHECK-NEXT: 5: 1 ; CHECK-NEXT: 6: 15 +; CHECK-NEXT: 7: 0 ; CHECK-NEXT: 8: 14 bar:14 +; CHECK-NEXT: 9: 0 ; CHECK-NEXT: !CFGChecksum: 138950591924 ; CHECK:[main:2 @ foo:8 @ bar]:28:14 ; CHECK-NEXT: 1: 14 -; CHECK-NEXT: 2: 18446744073709551615 -; CHECK-NEXT: 3: 18446744073709551615 ; CHECK-NEXT: 4: 14 ; CHECK-NEXT: !CFGChecksum: 72617220756 diff --git a/llvm/test/tools/llvm-profgen/merge-cold-profile.test b/llvm/test/tools/llvm-profgen/merge-cold-profile.test --- a/llvm/test/tools/llvm-profgen/merge-cold-profile.test +++ b/llvm/test/tools/llvm-profgen/merge-cold-profile.test @@ -12,10 +12,10 @@ ; CHECK: [fa]:14:4 ; CHECK-NEXT: 1: 4 -; CHECK-NEXT: 2: 18446744073709551615 ; CHECK-NEXT: 3: 4 ; CHECK-NEXT: 4: 2 ; CHECK-NEXT: 5: 1 +; CHECK-NEXT: 6: 0 ; CHECK-NEXT: 7: 2 fb:2 ; CHECK-NEXT: 8: 1 fa:1 ; CHECK-NEXT: !CFGChecksum: 120515930909 @@ -24,6 +24,7 @@ ; CHECK-NEXT: 1: 4 ; CHECK-NEXT: 2: 3 ; CHECK-NEXT: 3: 1 +; CHECK-NEXT: 4: 0 ; CHECK-NEXT: 5: 4 fb:4 ; CHECK-NEXT: 6: 1 fa:1 ; CHECK-NEXT: !CFGChecksum: 72617220756 @@ -32,16 +33,17 @@ ; CHECK-KEEP-COLD-NEXT: 1: 6 ; CHECK-KEEP-COLD-NEXT: 2: 3 ; CHECK-KEEP-COLD-NEXT: 3: 3 +; CHECK-KEEP-COLD-NEXT: 4: 0 ; CHECK-KEEP-COLD-NEXT: 5: 4 fb:4 ; CHECK-KEEP-COLD-NEXT: 6: 3 fa:3 ; CHECK-KEEP-COLD-NEXT: !CFGChecksum: 72617220756 ; CHECK-KEEP-COLD-NEXT: !Attributes: 0 ; CHECK-KEEP-COLD-NEXT:[fa]:14:4 ; CHECK-KEEP-COLD-NEXT: 1: 4 -; CHECK-KEEP-COLD-NEXT: 2: 18446744073709551615 ; CHECK-KEEP-COLD-NEXT: 3: 4 ; CHECK-KEEP-COLD-NEXT: 4: 2 ; CHECK-KEEP-COLD-NEXT: 5: 1 +; CHECK-KEEP-COLD-NEXT: 6: 0 ; CHECK-KEEP-COLD-NEXT: 7: 2 fb:2 ; CHECK-KEEP-COLD-NEXT: 8: 1 fa:1 ; CHECK-KEEP-COLD-NEXT: !CFGChecksum: 120515930909 @@ -50,6 +52,7 @@ ; CHECK-UNMERGED-NEXT: 1: 4 ; CHECK-UNMERGED-NEXT: 2: 3 ; CHECK-UNMERGED-NEXT: 3: 1 +; CHECK-UNMERGED-NEXT: 4: 0 ; CHECK-UNMERGED-NEXT: 5: 4 fb:4 ; CHECK-UNMERGED-NEXT: 6: 1 fa:1 ; CHECK-UNMERGED-NEXT: !CFGChecksum: 72617220756 diff --git a/llvm/test/tools/llvm-profgen/noinline-cs-pseudoprobe.test b/llvm/test/tools/llvm-profgen/noinline-cs-pseudoprobe.test --- a/llvm/test/tools/llvm-profgen/noinline-cs-pseudoprobe.test +++ b/llvm/test/tools/llvm-profgen/noinline-cs-pseudoprobe.test @@ -2,16 +2,18 @@ ; RUN: FileCheck %s --input-file %t ; CHECK: [main:2 @ foo]:75:0 +; CHECK-NEXT: 1: 0 ; CHECK-NEXT: 2: 15 ; CHECK-NEXT: 3: 15 ; CHECK-NEXT: 4: 15 +; CHECK-NEXT: 5: 0 ; CHECK-NEXT: 6: 15 +; CHECK-NEXT: 7: 0 ; CHECK-NEXT: 8: 15 bar:15 +; CHECK-NEXT: 9: 0 ; CHECK-NEXT: !CFGChecksum: 138950591924 ; CHECK:[main:2 @ foo:8 @ bar]:30:15 ; CHECK-NEXT: 1: 15 -; CHECK-NEXT: 2: 18446744073709551615 -; CHECK-NEXT: 3: 18446744073709551615 ; CHECK-NEXT: 4: 15 ; CHECK-NEXT: !CFGChecksum: 72617220756 diff --git a/llvm/test/tools/llvm-profgen/truncated-pseudoprobe.test b/llvm/test/tools/llvm-profgen/truncated-pseudoprobe.test --- a/llvm/test/tools/llvm-profgen/truncated-pseudoprobe.test +++ b/llvm/test/tools/llvm-profgen/truncated-pseudoprobe.test @@ -2,17 +2,19 @@ ; RUN: FileCheck %s --input-file %t ; CHECK: [foo]:75:0 +; CHECK-NEXT: 1: 0 ; CHECK-NEXT: 2: 15 ; CHECK-NEXT: 3: 15 ; CHECK-NEXT: 4: 15 +; CHECK-NEXT: 5: 0 ; CHECK-NEXT: 6: 15 +; CHECK-NEXT: 7: 0 ; CHECK-NEXT: 8: 15 bar:15 +; CHECK-NEXT: 9: 0 ; CHECK-NEXT: !CFGChecksum: 563088904013236 ; CHECK-NEXT: !Attributes: 0 ; CHECK: [foo:8 @ bar]:30:15 ; CHECK-NEXT: 1: 15 -; CHECK-NEXT: 2: 18446744073709551615 -; CHECK-NEXT: 3: 18446744073709551615 ; CHECK-NEXT: 4: 15 ; CHECK-NEXT: !CFGChecksum: 72617220756 ; CHECK-NEXT: !Attributes: 1 diff --git a/llvm/tools/llvm-profgen/ProfileGenerator.cpp b/llvm/tools/llvm-profgen/ProfileGenerator.cpp --- a/llvm/tools/llvm-profgen/ProfileGenerator.cpp +++ b/llvm/tools/llvm-profgen/ProfileGenerator.cpp @@ -549,19 +549,14 @@ } } - // Report dangling probes for frames that have real samples collected. - // Dangling probes are the probes associated to an empty block. With this - // place holder, sample count on a dangling probe will not be trusted by the - // compiler and we will rely on the counts inference algorithm to get the - // probe a reasonable count. Use InvalidProbeCount to mark sample count for - // a dangling probe. + // Report zero-count probes for frames that have real samples collected, + // instead of report dangling probes. This is mainly for saving the profile + // size. Dangling sampling can now be represented by a none/missing entry. for (auto &I : FrameSamples) { auto *FunctionProfile = I.second; for (auto *Probe : I.first->getProbes()) { - if (Probe->isDangling()) { - FunctionProfile->addBodySamplesForProbe( - Probe->Index, FunctionSamples::InvalidProbeCount); - } + if (!Probe->isDangling()) + FunctionProfile->addBodySamplesForProbe(Probe->Index, 0); } } }