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 +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 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;