[PATCH] D96811: [CSSPGO][llvm-profgen] Change sample count of dangling probe in llvm-profgen

Lei Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 4 00:12:02 PST 2021


wlei updated this revision to Diff 328043.
wlei added a comment.

address reviewers' feedback


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96811/new/

https://reviews.llvm.org/D96811

Files:
  llvm/test/tools/llvm-profgen/inline-cs-pseudoprobe.test
  llvm/test/tools/llvm-profgen/noinline-cs-pseudoprobe.test
  llvm/tools/llvm-profgen/ProfileGenerator.cpp


Index: llvm/tools/llvm-profgen/ProfileGenerator.cpp
===================================================================
--- llvm/tools/llvm-profgen/ProfileGenerator.cpp
+++ llvm/tools/llvm-profgen/ProfileGenerator.cpp
@@ -492,6 +492,22 @@
     FunctionSamples &FunctionProfile =
         getFunctionProfileForLeafProbe(ContextStrStack, Probe, Binary);
 
+    // Use InvalidProbeCount(UINT64_MAX) to mark sample count for a dangling
+    // probe. Dangling probes are the probes associated to an empty block. With
+    // this place holder, sample count on dangling probe will not be trusted by
+    // the compiler and it will rely on the counts inference algorithm to get
+    // the probe a reasonable count.
+    if (Probe->isDangling()) {
+      ErrorOr<uint64_t> R = FunctionProfile.findSamplesAt(Probe->Index, 0);
+      if (!R) {
+        FunctionProfile.addBodySamples(Probe->Index, 0,
+                                       FunctionSamples::InvalidProbeCount);
+      } else {
+        assert(R.get() == FunctionSamples::InvalidProbeCount &&
+               "Dangling probe count should be UINT64_MAX.");
+      }
+      continue;
+    }
     FunctionProfile.addBodySamples(Probe->Index, 0, Count);
     FunctionProfile.addTotalSamples(Count);
     if (Probe->isEntry()) {
Index: llvm/test/tools/llvm-profgen/noinline-cs-pseudoprobe.test
===================================================================
--- llvm/test/tools/llvm-profgen/noinline-cs-pseudoprobe.test
+++ llvm/test/tools/llvm-profgen/noinline-cs-pseudoprobe.test
@@ -8,10 +8,10 @@
 ; CHECK-NEXT: 6: 15
 ; CHECK-NEXT: 8: 15 bar:15
 ; CHECK-NEXT: !CFGChecksum: 138950591924
-; CHECK-NEXT:[main:2 @ foo:8 @ bar]:60:15
+; CHECK-NEXT:[main:2 @ foo:8 @ bar]:30:15
 ; CHECK-NEXT: 1: 15
-; CHECK-NEXT: 2: 15
-; CHECK-NEXT: 3: 15
+; CHECK-NEXT: 2: 18446744073709551615
+; CHECK-NEXT: 3: 18446744073709551615
 ; CHECK-NEXT: 4: 15
 ; CHECK-NEXT: !CFGChecksum: 72617220756
 
Index: llvm/test/tools/llvm-profgen/inline-cs-pseudoprobe.test
===================================================================
--- llvm/test/tools/llvm-profgen/inline-cs-pseudoprobe.test
+++ llvm/test/tools/llvm-profgen/inline-cs-pseudoprobe.test
@@ -9,10 +9,10 @@
 ; CHECK-NEXT: 6: 15
 ; CHECK-NEXT: 8: 14 bar:14
 ; CHECK-NEXT: !CFGChecksum: 138950591924
-; CHECK-NEXT:[main:2 @ foo:8 @ bar]:56:14
+; CHECK-NEXT:[main:2 @ foo:8 @ bar]:28:14
 ; CHECK-NEXT: 1: 14
-; CHECK-NEXT: 2: 14
-; CHECK-NEXT: 3: 14
+; CHECK-NEXT: 2: 18446744073709551615
+; CHECK-NEXT: 3: 18446744073709551615
 ; CHECK-NEXT: 4: 14
 ; CHECK-NEXT: !CFGChecksum: 72617220756
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96811.328043.patch
Type: text/x-patch
Size: 2591 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210304/72da6cdb/attachment.bin>


More information about the llvm-commits mailing list