diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2014-04-28 11:10:23 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2014-04-28 11:10:23 +0000 |
commit | c00a7ff4b70c24b82069f5cb44477ccc8b9203cc (patch) | |
tree | 8e68d3c06bd36aa61a7951ed35c4c10c7d53d875 /llvm/lib/Analysis/LazyCallGraph.cpp | |
parent | 3f5f5fe16434381e1fc375396278d4e379a291b0 (diff) | |
download | llvm-c00a7ff4b70c24b82069f5cb44477ccc8b9203cc.zip llvm-c00a7ff4b70c24b82069f5cb44477ccc8b9203cc.tar.gz llvm-c00a7ff4b70c24b82069f5cb44477ccc8b9203cc.tar.bz2 |
[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.
llvm-svn: 207411
Diffstat (limited to 'llvm/lib/Analysis/LazyCallGraph.cpp')
-rw-r--r-- | llvm/lib/Analysis/LazyCallGraph.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp index b593069..05757e1 100644 --- a/llvm/lib/Analysis/LazyCallGraph.cpp +++ b/llvm/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!"); |