aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-03-13 19:32:19 +0000
committerAnna Zaks <ganna@apple.com>2012-03-13 19:32:19 +0000
commitb990d039c7e01ad0055dcbd1e13a691813397b96 (patch)
tree812bbe60afa6a6f9194651066abe6230935fdbc6 /lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
parent7fe8dcef71ae56e43fd7df345db2895f84f2d0ca (diff)
[analyzer] Change the order in which we analyze the functions under
inlining to be the reverse of their declaration. This optimizes running time under inlining up to 20% since we do not re-analyze the utility functions which are usually defined first in the translation unit if they have already been analyzed while inlined into the root functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152653 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp')
-rw-r--r--lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
index e8903804f9..5cf9e31c5b 100644
--- a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -272,21 +272,25 @@ void AnalysisConsumer::HandleDeclsGallGraph(TranslationUnitDecl *TU) {
// Find the top level nodes - children of root + the unreachable (parentless)
// nodes.
llvm::SmallVector<CallGraphNode*, 24> TopLevelFunctions;
+ for (CallGraph::nodes_iterator TI = CG.parentless_begin(),
+ TE = CG.parentless_end(); TI != TE; ++TI) {
+ TopLevelFunctions.push_back(*TI);
+ NumFunctionTopLevel++;
+ }
CallGraphNode *Entry = CG.getRoot();
for (CallGraphNode::iterator I = Entry->begin(),
E = Entry->end(); I != E; ++I) {
TopLevelFunctions.push_back(*I);
NumFunctionTopLevel++;
}
- for (CallGraph::nodes_iterator TI = CG.parentless_begin(),
- TE = CG.parentless_end(); TI != TE; ++TI) {
- TopLevelFunctions.push_back(*TI);
- NumFunctionTopLevel++;
- }
+ // Make sure the nodes are sorted in order reverse of their definition in the
+ // translation unit. This step is very important for performance. It ensures
+ // that we analyze the root functions before the externally available
+ // subroutines.
std::queue<CallGraphNode*> BFSQueue;
- for (llvm::SmallVector<CallGraphNode*, 24>::iterator
- TI = TopLevelFunctions.begin(), TE = TopLevelFunctions.end();
+ for (llvm::SmallVector<CallGraphNode*, 24>::reverse_iterator
+ TI = TopLevelFunctions.rbegin(), TE = TopLevelFunctions.rend();
TI != TE; ++TI)
BFSQueue.push(*TI);