[PATCH] D56383: [XRay][tools] Use symbols instead of function id

Dean Michael Berris via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 7 03:44:30 PST 2019


dberris created this revision.
dberris added a reviewer: mboerger.

In the graph-diff tool, we should use the symbol name for the labels in
the graph instead of the function ids.


https://reviews.llvm.org/D56383

Files:
  llvm/tools/llvm-xray/xray-graph-diff.cpp


Index: llvm/tools/llvm-xray/xray-graph-diff.cpp
===================================================================
--- llvm/tools/llvm-xray/xray-graph-diff.cpp
+++ llvm/tools/llvm-xray/xray-graph-diff.cpp
@@ -332,23 +332,40 @@
   }
 }
 
+template <typename T>
+static std::string anySymbol(const T &Collection, const StringRef &DefValue) {
+  for (const auto &E : Collection)
+    if (E != nullptr)
+      return E->second.SymbolName;
+  return DefValue;
+}
+
 static std::string getLabel(const GraphDiffRenderer::GraphT::VertexValueType &V,
                             GraphDiffRenderer::StatType VL, int TrunLen) {
   const auto &VertexId = V.first;
   const auto &VertexAttr = V.second;
   switch (VL) {
   case GraphDiffRenderer::StatType::NONE:
-    return formatv(R"({0})", truncateString(VertexId, TrunLen).str());
+    return formatv(
+        R"({0})",
+        truncateString(anySymbol(VertexAttr.CorrVertexPtr, VertexId), TrunLen)
+            .str());
   default:
     if (containsNullptr(VertexAttr.CorrVertexPtr))
-      return formatv(R"({0})", truncateString(VertexId, TrunLen).str());
+      return formatv(
+          R"({0})",
+          truncateString(anySymbol(VertexAttr.CorrVertexPtr, VertexId), TrunLen)
+              .str());
 
     const auto &LeftStat = VertexAttr.CorrVertexPtr[0]->second.S;
     const auto &RightStat = VertexAttr.CorrVertexPtr[1]->second.S;
 
     double RelDiff = statRelDiff(LeftStat, RightStat, VL);
-    return formatv(R"({{{0}|{1:P}})", truncateString(VertexId, TrunLen).str(),
-                   RelDiff);
+    return formatv(
+        R"({{{0}|{1:P}})",
+        truncateString(VertexAttr.CorrVertexPtr[0]->second.SymbolName, TrunLen)
+            .str(),
+        RelDiff);
   }
 }
 
@@ -419,7 +436,7 @@
 }
 
 template <typename T> static T &ifSpecified(T &A, cl::alias &AA, T &B) {
-  if (A.getPosition() == 0 && AA.getPosition() == 0)
+  if (A.getPosition() == 0)
     return B;
 
   return A;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56383.180453.patch
Type: text/x-patch
Size: 1955 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190107/9fa72dfa/attachment.bin>


More information about the llvm-commits mailing list