[PATCH] D114284: [llvm-profgen] Truncate the context with zero probe ID

Lei Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 19 14:01:34 PST 2021


wlei created this revision.
Herald added subscribers: hoy, wenlei, lxfind.
wlei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114284

Files:
  llvm/tools/llvm-profgen/ProfiledBinary.h


Index: llvm/tools/llvm-profgen/ProfiledBinary.h
===================================================================
--- llvm/tools/llvm-profgen/ProfiledBinary.h
+++ llvm/tools/llvm-profgen/ProfiledBinary.h
@@ -32,6 +32,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Transforms/IPO/SampleContextTracker.h"
+#include <bits/stdint-uintn.h>
 #include <list>
 #include <map>
 #include <set>
@@ -454,7 +455,13 @@
     SmallVector<MCPseduoProbeFrameLocation, 16> ProbeInlineContext;
     ProbeDecoder.getInlineContextForProbe(Probe, ProbeInlineContext,
                                           IncludeLeaf);
-    for (auto &Callsite : ProbeInlineContext) {
+    for (uint32_t I = 0; I < ProbeInlineContext.size(); I++) {
+      auto &Callsite = ProbeInlineContext[I];
+      // Ignore the context if the probe of the callsite is zero.
+      if(Callsite.second == 0 && I != ProbeInlineContext.size() - 1) {
+        InlineContextStack.clear();
+        continue;
+      }
       InlineContextStack.emplace_back(Callsite.first,
                                       LineLocation(Callsite.second, 0));
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114284.388622.patch
Type: text/x-patch
Size: 1148 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211119/1ff05f6c/attachment.bin>


More information about the llvm-commits mailing list