summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Frontend
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
commit943c680605b42ed83c0ac10e93d5bbf57a9b4d24 (patch)
treed95a9ecfb9789e652a5ec042dfe1692e24386111 /clang/lib/StaticAnalyzer/Frontend
parentca70ed53dab97506c07350b2798e281bf0595491 (diff)
downloadbcm5719-llvm-943c680605b42ed83c0ac10e93d5bbf57a9b4d24.tar.gz
bcm5719-llvm-943c680605b42ed83c0ac10e93d5bbf57a9b4d24.zip
[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. llvm-svn: 152653
Diffstat (limited to 'clang/lib/StaticAnalyzer/Frontend')
-rw-r--r--clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
index e8903804f91..5cf9e31c5b0 100644
--- a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ b/clang/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);
OpenPOWER on IntegriCloud