Path: blob/main/contrib/llvm-project/llvm/tools/llvm-xray/xray-graph-diff.h
35231 views
//===-- xray-graph-diff.h - XRay Graph Diff Renderer ------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// Generate a DOT file to represent the difference between the function call9// graph of two differnent traces.10//11//===----------------------------------------------------------------------===//1213#ifndef XRAY_GRAPH_DIFF_H14#define XRAY_GRAPH_DIFF_H1516#include "xray-graph.h"17#include "llvm/XRay/Graph.h"1819namespace llvm {20namespace xray {2122// This class creates a graph representing the difference between two23// xray-graphs And allows you to print it to a dot file, with optional color24// coding.25class GraphDiffRenderer {26static const int N = 2;2728public:29using StatType = GraphRenderer::StatType;30using TimeStat = GraphRenderer::TimeStat;3132using GREdgeValueType = GraphRenderer::GraphT::EdgeValueType;33using GRVertexValueType = GraphRenderer::GraphT::VertexValueType;3435struct EdgeAttribute {36std::array<const GREdgeValueType *, N> CorrEdgePtr = {};37};3839struct VertexAttribute {40std::array<const GRVertexValueType *, N> CorrVertexPtr = {};41};4243using GraphT = Graph<VertexAttribute, EdgeAttribute, StringRef>;4445class Factory {46std::array<std::reference_wrapper<const GraphRenderer::GraphT>, N> G;4748public:49template <typename... Ts> Factory(Ts &... Args) : G{{Args...}} {}5051Expected<GraphDiffRenderer> getGraphDiffRenderer();52};5354private:55GraphT G;5657GraphDiffRenderer() = default;5859public:60void exportGraphAsDOT(raw_ostream &OS, StatType EdgeLabel = StatType::NONE,61StatType EdgeColor = StatType::NONE,62StatType VertexLabel = StatType::NONE,63StatType VertexColor = StatType::NONE,64int TruncLen = 40);6566const GraphT &getGraph() { return G; }67};68} // namespace xray69} // namespace llvm7071#endif727374