LLVM: lib/Analysis/DDGPrinter.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
18
19using namespace llvm;
20
22 cl::desc("simple ddg dot graph"));
25 cl::desc("The prefix used for the DDG dot file names."));
26
28
29
30
31
38
40 std::string Filename =
42 errs() << "Writing '" << Filename << "'...";
43
44 std::error_code EC;
46
47 if (!EC)
48
49
51 else
52 errs() << " error opening file for writing!";
53 errs() << "\n";
54}
55
56
57
58
59std::string DDGDotGraphTraits::getNodeLabel(const DDGNode *Node,
62 return getSimpleNodeLabel(Node, Graph);
63 else
64 return getVerboseNodeLabel(Node, Graph);
65}
66
67std::string DDGDotGraphTraits::getEdgeAttributes(
70 const DDGEdge *E = static_cast<const DDGEdge *>(*I.getCurrent());
72 return getSimpleEdgeAttributes(Node, E, G);
73 else
74 return getVerboseEdgeAttributes(Node, E, G);
75}
76
77bool DDGDotGraphTraits::isNodeHidden(const DDGNode *Node,
80 return true;
81 assert(Graph && "expected a valid graph pointer");
82 return Graph->getPiBlock(*Node) != nullptr;
83}
84
85std::string
86DDGDotGraphTraits::getSimpleNodeLabel(const DDGNode *Node,
88 std::string Str;
89 raw_string_ostream OS(Str);
91 for (auto *II : static_cast<const SimpleDDGNode *>(Node)->getInstructions())
92 OS << *II << "\n";
94 OS << "pi-block\nwith\n"
97 OS << "root\n";
98 else
100 return OS.str();
101}
102
103std::string
104DDGDotGraphTraits::getVerboseNodeLabel(const DDGNode *Node,
106 std::string Str;
107 raw_string_ostream OS(Str);
108 OS << "<kind:" << Node->getKind() << ">\n";
110 for (auto *II : static_cast<const SimpleDDGNode *>(Node)->getInstructions())
111 OS << *II << "\n";
113 OS << "--- start of nodes in pi-block ---\n";
114 unsigned Count = 0;
116 for (auto *PN : PNodes) {
117 OS << getVerboseNodeLabel(PN, G);
118 if (++Count != PNodes.size())
119 OS << "\n";
120 }
121 OS << "--- end of nodes in pi-block ---\n";
123 OS << "root\n";
124 else
126 return OS.str();
127}
128
129std::string DDGDotGraphTraits::getSimpleEdgeAttributes(
131 std::string Str;
132 raw_string_ostream OS(Str);
134 OS << "label=\"[" << Kind << "]\"";
135 return OS.str();
136}
137
138std::string DDGDotGraphTraits::getVerboseEdgeAttributes(
140 std::string Str;
141 raw_string_ostream OS(Str);
143 OS << "label=\"[";
145 OS << G->getDependenceString(*Src, Edge->getTargetNode());
146 else
148 OS << "]\"";
149 return OS.str();
150}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static void writeDDGToDotFile(DataDependenceGraph &G, bool DOnly=false)
Definition DDGPrinter.cpp:39
static cl::opt< bool > DotOnly("dot-ddg-only", cl::Hidden, cl::desc("simple ddg dot graph"))
static cl::opt< std::string > DDGDotFilenamePrefix("dot-ddg-filename-prefix", cl::init("ddg"), cl::Hidden, cl::desc("The prefix used for the DDG dot file names."))
uint64_t IntrinsicInst * II
std::pair< BasicBlock *, BasicBlock * > Edge
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Analysis pass that builds the DDG for a loop.
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U)
Definition DDGPrinter.cpp:32
Data Dependency Graph Edge.
EdgeKind
The kind of edge in the DDG.
Data Dependence Graph Node The graph can represent the following types of nodes:
const PiBlockDDGNode * getPiBlock(const NodeType &N) const
If node N belongs to a pi-block return a pointer to the pi-block, otherwise return null.
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
Represents a single loop in the control flow graph.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM_ABI std::string str() const
Return the twine contents as a std::string.
A raw_ostream that writes to a file descriptor.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
initializer< Ty > init(const Ty &Val)
NodeAddr< NodeBase * > Node
@ OF_Text
The file should be opened in text mode on platforms like z/OS that make this distinction.
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & WriteGraph(raw_ostream &O, const GraphType &G, bool ShortNames=false, const Twine &Title="")
AnalysisManager< Loop, LoopStandardAnalysisResults & > LoopAnalysisManager
The loop analysis manager.
FunctionAddr VTableAddr Count
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...