1 //===-- xray-graph-diff.h - XRay Graph Diff Renderer ------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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"
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
28 class GraphDiffRenderer
{
29 static const int N
= 2;
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
>;
49 std::array
<std::reference_wrapper
<const GraphRenderer::GraphT
>, N
> G
;
52 template <typename
... Ts
> Factory(Ts
&... Args
) : G
{{Args
...}} {}
54 Expected
<GraphDiffRenderer
> getGraphDiffRenderer();
60 GraphDiffRenderer() = default;
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
,
69 const GraphT
&getGraph() { return G
; }