[LCG] Add the most basic of edge insertion to the lazy call graph. This
[oota-llvm.git] / lib / Analysis / LazyCallGraph.cpp
index b593069e66443b369daddbac8a6543efc1c3943a..05757e1e2f5830b279479152c15433310369af03 100644 (file)
@@ -75,6 +75,14 @@ LazyCallGraph::Node::Node(LazyCallGraph &G, Function &F)
   findCallees(Worklist, Visited, Callees, CalleeIndexMap);
 }
 
+void LazyCallGraph::Node::insertEdgeInternal(Function &Callee) {
+  CalleeIndexMap.insert(std::make_pair(&Callee, Callees.size()));
+  if (Node *N = G->lookup(Callee))
+    Callees.push_back(N);
+  else
+    Callees.push_back(&Callee);
+}
+
 void LazyCallGraph::Node::removeEdgeInternal(Function &Callee) {
   auto IndexMapI = CalleeIndexMap.find(&Callee);
   assert(IndexMapI != CalleeIndexMap.end() &&
@@ -353,6 +361,13 @@ LazyCallGraph::SCC::removeIntraSCCEdge(Node &CallerN,
   return ResultSCCs;
 }
 
+void LazyCallGraph::insertEdge(Node &CallerN, Function &Callee) {
+  assert(SCCMap.empty() && DFSStack.empty() &&
+         "This method cannot be called after SCCs have been formed!");
+
+  return CallerN.insertEdgeInternal(Callee);
+}
+
 void LazyCallGraph::removeEdge(Node &CallerN, Function &Callee) {
   assert(SCCMap.empty() && DFSStack.empty() &&
          "This method cannot be called after SCCs have been formed!");