diff options
author | Douglas Gregor <dgregor@apple.com> | 2013-01-25 23:32:03 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2013-01-25 23:32:03 +0000 |
commit | 7211ac15bbd97fd9ea8016a6632cb039a1071f1d (patch) | |
tree | 13674728016d428fb1e74988296e7bf1155b3e33 /clang/lib/Serialization/ASTReader.cpp | |
parent | 8653bcf024708d6d836b4e214d0ff4872798e0f8 (diff) | |
download | bcm5719-llvm-7211ac15bbd97fd9ea8016a6632cb039a1071f1d.tar.gz bcm5719-llvm-7211ac15bbd97fd9ea8016a6632cb039a1071f1d.zip |
Improve coordination between the module manager and the global module
index, optimizing the operation that skips lookup in modules where we
know the identifier will not be found. This makes the global module
index optimization actually useful, providing an 8.5% speedup over
modules without the global module index for -fsyntax-only.
llvm-svn: 173529
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index d8d5e664f08..fd1b8966ee2 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -1378,17 +1378,15 @@ namespace { class IdentifierLookupVisitor { StringRef Name; unsigned PriorGeneration; - GlobalModuleIndex::SkipSet &SkipSet; unsigned &NumIdentifierLookups; unsigned &NumIdentifierLookupHits; IdentifierInfo *Found; public: IdentifierLookupVisitor(StringRef Name, unsigned PriorGeneration, - GlobalModuleIndex::SkipSet &SkipSet, unsigned &NumIdentifierLookups, unsigned &NumIdentifierLookupHits) - : Name(Name), PriorGeneration(PriorGeneration), SkipSet(SkipSet), + : Name(Name), PriorGeneration(PriorGeneration), NumIdentifierLookups(NumIdentifierLookups), NumIdentifierLookupHits(NumIdentifierLookupHits), Found() @@ -1403,10 +1401,6 @@ namespace { if (M.Generation <= This->PriorGeneration) return true; - // If this module file is in the skip set, don't bother looking in it. - if (This->SkipSet.count(M.File)) - return false; - ASTIdentifierLookupTable *IdTable = (ASTIdentifierLookupTable *)M.IdentifierLookupTable; if (!IdTable) @@ -1443,18 +1437,18 @@ void ASTReader::updateOutOfDateIdentifier(IdentifierInfo &II) { // If there is a global index, look there first to determine which modules // provably do not have any results for this identifier. - GlobalModuleIndex::SkipSet SkipSet; + GlobalModuleIndex::HitSet Hits; + GlobalModuleIndex::HitSet *HitsPtr = 0; if (!loadGlobalIndex()) { - SmallVector<const FileEntry *, 4> ModuleFiles; - if (GlobalIndex->lookupIdentifier(II.getName(), ModuleFiles)) { - SkipSet = GlobalIndex->computeSkipSet(ModuleFiles); + if (GlobalIndex->lookupIdentifier(II.getName(), Hits)) { + HitsPtr = &Hits; } } - IdentifierLookupVisitor Visitor(II.getName(), PriorGeneration, SkipSet, + IdentifierLookupVisitor Visitor(II.getName(), PriorGeneration, NumIdentifierLookups, NumIdentifierLookupHits); - ModuleMgr.visit(IdentifierLookupVisitor::visit, &Visitor); + ModuleMgr.visit(IdentifierLookupVisitor::visit, &Visitor, HitsPtr); markIdentifierUpToDate(&II); } @@ -2695,6 +2689,7 @@ bool ASTReader::loadGlobalIndex() { return true; GlobalIndex.reset(Result.first); + ModuleMgr.setGlobalIndex(GlobalIndex.get()); return false; } @@ -2725,6 +2720,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName, // If we find that any modules are unusable, the global index is going // to be out-of-date. Just remove it. GlobalIndex.reset(); + ModuleMgr.setGlobalIndex(0); return ReadResult; case Success: @@ -5760,17 +5756,17 @@ IdentifierInfo* ASTReader::get(const char *NameStart, const char *NameEnd) { // If there is a global index, look there first to determine which modules // provably do not have any results for this identifier. - GlobalModuleIndex::SkipSet SkipSet; + GlobalModuleIndex::HitSet Hits; + GlobalModuleIndex::HitSet *HitsPtr = 0; if (!loadGlobalIndex()) { - SmallVector<const FileEntry *, 4> ModuleFiles; - if (GlobalIndex->lookupIdentifier(Name, ModuleFiles)) { - SkipSet = GlobalIndex->computeSkipSet(ModuleFiles); + if (GlobalIndex->lookupIdentifier(Name, Hits)) { + HitsPtr = &Hits; } } - IdentifierLookupVisitor Visitor(Name, /*PriorGeneration=*/0, SkipSet, + IdentifierLookupVisitor Visitor(Name, /*PriorGeneration=*/0, NumIdentifierLookups, NumIdentifierLookupHits); - ModuleMgr.visit(IdentifierLookupVisitor::visit, &Visitor); + ModuleMgr.visit(IdentifierLookupVisitor::visit, &Visitor, HitsPtr); IdentifierInfo *II = Visitor.getIdentifierInfo(); markIdentifierUpToDate(II); return II; |