return NI->get<Node *>();
Function *F = NI->get<Function *>();
- Node *ChildN = G->get(*F);
- *NI = ChildN;
- return ChildN;
+ Node &ChildN = G->get(*F);
+ *NI = &ChildN;
+ return &ChildN;
}
pointer operator->() const { return operator*(); }
/// \brief Get a graph node for a given function, scanning it to populate the
/// graph data as necessary.
- Node *get(Function &F) {
+ Node &get(Function &F) {
Node *&N = NodeMap[&F];
if (N)
- return N;
+ return *N;
return insertInto(F, N);
}
/// \brief Update the call graph after deleting an edge.
void removeEdge(Function &Caller, Function &Callee) {
- return removeEdge(*get(Caller), Callee);
+ return removeEdge(get(Caller), Callee);
}
private:
/// \brief Helper to insert a new function, with an already looked-up entry in
/// the NodeMap.
- Node *insertInto(Function &F, Node *&MappedN);
+ Node &insertInto(Function &F, Node *&MappedN);
/// \brief Helper to update pointers back to the graph object during moves.
void updateGraphPtrs();
CallerC->removeInternalEdge(*this, CallerN, *CalleeN);
}
-LazyCallGraph::Node *LazyCallGraph::insertInto(Function &F, Node *&MappedN) {
- return new (MappedN = BPA.Allocate()) Node(*this, F);
+LazyCallGraph::Node &LazyCallGraph::insertInto(Function &F, Node *&MappedN) {
+ return *new (MappedN = BPA.Allocate()) Node(*this, F);
}
void LazyCallGraph::updateGraphPtrs() {
// Reset the DFS numbering.
NextDFSNumber = 1;
- Node *N = get(*SCCEntryNodes.pop_back_val());
- DFSStack.push_back(std::make_pair(N, N->begin()));
+ Node &N = get(*SCCEntryNodes.pop_back_val());
+ DFSStack.push_back(std::make_pair(&N, N.begin()));
}
auto SI = DFSStack.rbegin();