summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LazyCallGraph.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-04-23 08:08:49 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-04-23 08:08:49 +0000
commitc7bad9a5a0385ac7884c2269531f820f3b003c18 (patch)
treed622daca91d86402c83df27112a6f29643ababc4 /llvm/lib/Analysis/LazyCallGraph.cpp
parent8ac0bf96f068f9ae29d931662faab75616a6e59a (diff)
downloadbcm5719-llvm-c7bad9a5a0385ac7884c2269531f820f3b003c18.tar.gz
bcm5719-llvm-c7bad9a5a0385ac7884c2269531f820f3b003c18.zip
[LCG] Add a unittest for the LazyCallGraph. I had a weak moment and
resisted this for too long. Just with the basic testing here I was able to exercise the analysis in more detail and sift out both type signature bugs in the API and a bug in the DFS numbering. All of these are fixed here as well. The unittests will be much more important for the mutation support where it is necessary to craft minimal mutations and then inspect the state of the graph. There is just no way to do that with a standard FileCheck test. However, unittesting these kinds of analyses is really quite easy, especially as they're designed with the new pass manager where there is essentially no infrastructure required to rig up the core logic and exercise it at an API level. As a minor aside about the DFS numbering bug, the DFS numbering used in LCG is a bit unusual. Rather than numbering from 0, we number from 1, and use 0 as the sentinel "unvisited" state. Other implementations often use '-1' for this, but I find it easier to deal with 0 and it shouldn't make any real difference provided someone doesn't write silly bugs like forgetting to actually initialize the DFS numbering. Oops. ;] llvm-svn: 206954
Diffstat (limited to 'llvm/lib/Analysis/LazyCallGraph.cpp')
-rw-r--r--llvm/lib/Analysis/LazyCallGraph.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp
index cb5c052c182..0a71b9d2758 100644
--- a/llvm/lib/Analysis/LazyCallGraph.cpp
+++ b/llvm/lib/Analysis/LazyCallGraph.cpp
@@ -203,6 +203,8 @@ LazyCallGraph::SCC *LazyCallGraph::getNextSCCInPostOrder() {
if (SCCEntryNodes.empty())
return nullptr;
+ // Reset the DFS numbering.
+ NextDFSNumber = 1;
Node *N = get(*SCCEntryNodes.pop_back_val());
DFSStack.push_back(std::make_pair(N, N->begin()));
}
OpenPOWER on IntegriCloud