From db0b52c8e09e7cbb3452d4560dfeb1c933034794 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 28 Apr 2014 11:10:23 +0000 Subject: [LCG] Add the most basic of edge insertion to the lazy call graph. This just handles the pre-DFS case. Also add some test cases for this case to make sure it works. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207411 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/LazyCallGraph.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/Analysis/LazyCallGraph.cpp') diff --git a/lib/Analysis/LazyCallGraph.cpp b/lib/Analysis/LazyCallGraph.cpp index b593069e66..05757e1e2f 100644 --- a/lib/Analysis/LazyCallGraph.cpp +++ b/lib/Analysis/LazyCallGraph.cpp @@ -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!"); -- cgit v1.2.3