Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/CodeGen/ScheduleDAGPrinter.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- ScheduleDAGPrinter.cpp - Implement ScheduleDAG::viewGraph() -------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This implements the ScheduleDAG::viewGraph method.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "llvm/ADT/StringExtras.h"
14
#include "llvm/CodeGen/MachineConstantPool.h"
15
#include "llvm/CodeGen/MachineFunction.h"
16
#include "llvm/CodeGen/ScheduleDAG.h"
17
#include "llvm/CodeGen/TargetRegisterInfo.h"
18
#include "llvm/IR/Constants.h"
19
#include "llvm/Support/Debug.h"
20
#include "llvm/Support/GraphWriter.h"
21
#include "llvm/Support/raw_ostream.h"
22
using namespace llvm;
23
24
namespace llvm {
25
  template<>
26
  struct DOTGraphTraits<ScheduleDAG*> : public DefaultDOTGraphTraits {
27
28
0
  DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
29
30
0
    static std::string getGraphName(const ScheduleDAG *G) {
31
0
      return G->MF.getName();
32
0
    }
33
34
0
    static bool renderGraphFromBottomUp() {
35
0
      return true;
36
0
    }
37
38
0
    static bool isNodeHidden(const SUnit *Node) {
39
0
      return (Node->NumPreds > 10 || Node->NumSuccs > 10);
40
0
    }
41
42
    static std::string getNodeIdentifierLabel(const SUnit *Node,
43
0
                                              const ScheduleDAG *Graph) {
44
0
      std::string R;
45
0
      raw_string_ostream OS(R);
46
0
      OS << static_cast<const void *>(Node);
47
0
      return R;
48
0
    }
49
50
    /// If you want to override the dot attributes printed for a particular
51
    /// edge, override this method.
52
    static std::string getEdgeAttributes(const SUnit *Node,
53
                                         SUnitIterator EI,
54
0
                                         const ScheduleDAG *Graph) {
55
0
      if (EI.isArtificialDep())
56
0
        return "color=cyan,style=dashed";
57
0
      if (EI.isCtrlDep())
58
0
        return "color=blue,style=dashed";
59
0
      return "";
60
0
    }
61
62
63
    std::string getNodeLabel(const SUnit *SU, const ScheduleDAG *Graph);
64
    static std::string getNodeAttributes(const SUnit *N,
65
0
                                         const ScheduleDAG *Graph) {
66
0
      return "shape=Mrecord";
67
0
    }
68
69
    static void addCustomGraphFeatures(ScheduleDAG *G,
70
0
                                       GraphWriter<ScheduleDAG*> &GW) {
71
0
      return G->addCustomGraphFeatures(GW);
72
0
    }
73
  };
74
}
75
76
std::string DOTGraphTraits<ScheduleDAG*>::getNodeLabel(const SUnit *SU,
77
0
                                                       const ScheduleDAG *G) {
78
0
  return G->getGraphNodeLabel(SU);
79
0
}
80
81
/// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
82
/// rendered using 'dot'.
83
///
84
0
void ScheduleDAG::viewGraph(const Twine &Name, const Twine &Title) {
85
0
  // This code is only for debugging!
86
#ifndef NDEBUG
87
  ViewGraph(this, Name, false, Title);
88
#else
89
  errs() << "ScheduleDAG::viewGraph is only available in debug builds on "
90
0
         << "systems with Graphviz or gv!\n";
91
0
#endif  // NDEBUG
92
0
}
93
94
/// Out-of-line implementation with no arguments is handy for gdb.
95
0
void ScheduleDAG::viewGraph() {
96
0
  viewGraph(getDAGName(), "Scheduling-Units Graph for " + getDAGName());
97
0
}