From 1a49d97d762570027863e9209af81d445e4f1502 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 25 Jan 2013 01:03:03 +0000 Subject: Implement the reader of the global module index and wire it into the AST reader. The global module index tracks all of the identifiers known to a set of module files. Lookup of those identifiers looks first in the global module index, which returns the set of module files in which that identifier can be found. The AST reader only needs to look into those module files and any module files not known to the global index (e.g., because they were (re)built after the global index), reducing the number of on-disk hash tables to visit. For an example source I'm looking at, we go from 237844 total identifier lookups into on-disk hash tables down to 126817. Unfortunately, this does not translate into a performance advantage. At best, it's a wash once the global module index has been built, but that's ignore the cost of building the global module index (which is itself fairly large). Profiles show that the global module index code is far less efficient than it should be; optimizing it might give enough of an advantage to justify its continued inclusion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173405 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Serialization/ModuleManager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/Serialization/ModuleManager.cpp') diff --git a/lib/Serialization/ModuleManager.cpp b/lib/Serialization/ModuleManager.cpp index 7cc1544259..c600c053b5 100644 --- a/lib/Serialization/ModuleManager.cpp +++ b/lib/Serialization/ModuleManager.cpp @@ -180,8 +180,7 @@ void ModuleManager::visit(bool (*Visitor)(ModuleFile &M, void *UserData), if (Visitor(*CurrentModule, UserData)) { // The visitor has requested that cut off visitation of any // module that the current module depends on. To indicate this - // behavior, we mark all of the reachable modules as having N - // incoming edges (which is impossible otherwise). + // behavior, we mark all of the reachable modules as "skipped". SmallVector Stack; Stack.push_back(CurrentModule); Skipped[CurrentModule->Index] = true; @@ -210,6 +209,8 @@ void ModuleManager::visit(bool (*Visitor)(ModuleFile &M, void *UserData), M = CurrentModule->Imports.begin(), MEnd = CurrentModule->Imports.end(); M != MEnd; ++M) { + if (Skipped[(*M)->Index]) + continue; // Remove our current module as an impediment to visiting the // module we depend on. If we were the last unvisited module -- cgit v1.2.3