Lines Matching defs:node
31 /// Returns true if this node refers to the indirect/external node.
34 /// Return the callable region this node represents. This can only be called
37 assert(!isExternal() && "the external node has no callable region");
41 /// Adds an reference edge to the given node. This is only valid on the
42 /// external node.
43 void CallGraphNode::addAbstractEdge(CallGraphNode *node) {
45 addEdge(node, Edge::Kind::Abstract);
48 /// Add an outgoing call edge from this node.
49 void CallGraphNode::addCallEdge(CallGraphNode *node) {
50 addEdge(node, Edge::Kind::Call);
53 /// Adds a reference edge to the given child node.
58 /// Returns true if this node has any child edges.
63 /// Add an edge to 'node' with the given kind.
64 void CallGraphNode::addEdge(CallGraphNode *node, Edge::Kind kind) {
65 edges.insert({node, kind});
78 // If there is no parent node, we ignore this operation. Even if this
79 // operation was a call, there would be no callgraph node to attribute it
112 /// Get or add a call graph node for the given region.
117 std::unique_ptr<CallGraphNode> &node = nodes[region];
118 if (!node) {
119 node.reset(new CallGraphNode(region));
121 // Add this node to the given parent node if necessary.
123 parentNode->addChildEdge(node.get());
125 // Otherwise, connect all callable nodes to the external node, this allows
131 externalCallerNode.addAbstractEdge(node.get());
134 return node.get();
137 /// Lookup a call graph node for the given region, or nullptr if none is
144 /// Resolve the callable for given callee to a node in the callgraph, or the
145 /// unknown callee node if a valid node was not resolved.
151 if (auto *node = lookupNode(callableOp.getCallableRegion()))
152 return node;
157 /// Erase the given node from the callgraph.
158 void CallGraph::eraseNode(CallGraphNode *node) {
159 // Erase any children of this node first.
160 if (node->hasChildren()) {
161 for (const CallGraphNode::Edge &edge : llvm::make_early_inc_range(*node))
165 // Erase any edges to this node from any other nodes.
167 it.second->edges.remove_if([node](const CallGraphNode::Edge &edge) {
168 return edge.getTarget() == node;
171 nodes.erase(node->getCallableRegion());
182 // Functor used to output the name for the given node.
183 auto emitNodeName = [&](const CallGraphNode *node) {
184 if (node == getExternalCallerNode()) {
188 if (node == getUnknownCalleeNode()) {
193 auto *callableRegion = node->getCallableRegion();
203 const CallGraphNode *node = nodeIt.second.get();
205 // Dump the header for this node.
207 emitNodeName(node);
211 for (auto &edge : *node) {
229 for (auto &node : scc) {
231 emitNodeName(node);