[PowerPC] Recommit r340016 after fixing the reported issue
[llvm-core.git] / tools / llvm-xray / xray-graph-diff.h
blob5abec91d858258c976f0f9b9244a7484103d071a
1 //===-- xray-graph-diff.h - XRay Graph Diff Renderer ------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Generate a DOT file to represent the difference between the function call
11 // graph of two differnent traces.
13 //===----------------------------------------------------------------------===//
15 #ifndef XRAY_GRAPH_DIFF_H
16 #define XRAY_GRAPH_DIFF_H
18 #include "xray-graph.h"
19 #include "llvm/ADT/StringMap.h"
20 #include "llvm/XRay/Graph.h"
22 namespace llvm {
23 namespace xray {
25 // This class creates a graph representing the difference between two
26 // xray-graphs And allows you to print it to a dot file, with optional color
27 // coding.
28 class GraphDiffRenderer {
29 static const int N = 2;
31 public:
32 using StatType = GraphRenderer::StatType;
33 using TimeStat = GraphRenderer::TimeStat;
35 using GREdgeValueType = GraphRenderer::GraphT::EdgeValueType;
36 using GRVertexValueType = GraphRenderer::GraphT::VertexValueType;
38 struct EdgeAttribute {
39 std::array<const GREdgeValueType *, N> CorrEdgePtr = {};
42 struct VertexAttribute {
43 std::array<const GRVertexValueType *, N> CorrVertexPtr = {};
46 using GraphT = Graph<VertexAttribute, EdgeAttribute, StringRef>;
48 class Factory {
49 std::array<std::reference_wrapper<const GraphRenderer::GraphT>, N> G;
51 public:
52 template <typename... Ts> Factory(Ts &... Args) : G{{Args...}} {}
54 Expected<GraphDiffRenderer> getGraphDiffRenderer();
57 private:
58 GraphT G;
60 GraphDiffRenderer() = default;
62 public:
63 void exportGraphAsDOT(raw_ostream &OS, StatType EdgeLabel = StatType::NONE,
64 StatType EdgeColor = StatType::NONE,
65 StatType VertexLabel = StatType::NONE,
66 StatType VertexColor = StatType::NONE,
67 int TruncLen = 40);
69 const GraphT &getGraph() { return G; }
71 } // namespace xray
72 } // namespace llvm
74 #endif