diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-25 01:14:32 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-25 01:14:32 +0000 |
commit | d1f01d79e5a2bc591a170a5ac95cee19dcaa8f57 (patch) | |
tree | ba11bff2225eba9504fe890706d90a39f55f1070 /clang/lib/Serialization/ASTReader.cpp | |
parent | 63db9717a56d957301349729fb2083f7b55caba8 (diff) | |
download | bcm5719-llvm-d1f01d79e5a2bc591a170a5ac95cee19dcaa8f57.tar.gz bcm5719-llvm-d1f01d79e5a2bc591a170a5ac95cee19dcaa8f57.zip |
Introduce a generation number for selector lookups in the global
method pool, so that we don't perform the same lookups into the same
PCH/module file repeatedly.
llvm-svn: 148895
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 6fa680a74f8..d336eb15472 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -5212,13 +5212,15 @@ IdentifierIterator *ASTReader::getIdentifiers() const { namespace clang { namespace serialization { class ReadMethodPoolVisitor { ASTReader &Reader; - Selector Sel; + Selector Sel; + unsigned PriorGeneration; llvm::SmallVector<ObjCMethodDecl *, 4> InstanceMethods; llvm::SmallVector<ObjCMethodDecl *, 4> FactoryMethods; public: - ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel) - : Reader(Reader), Sel(Sel) { } + ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel, + unsigned PriorGeneration) + : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration) { } static bool visit(ModuleFile &M, void *UserData) { ReadMethodPoolVisitor *This @@ -5227,6 +5229,10 @@ namespace clang { namespace serialization { if (!M.SelectorLookupTable) return false; + // If we've already searched this module file, skip it now. + if (M.Generation <= This->PriorGeneration) + return true; + ASTSelectorLookupTable *PoolTable = (ASTSelectorLookupTable*)M.SelectorLookupTable; ASTSelectorLookupTable::iterator Pos = PoolTable->find(This->Sel); @@ -5269,7 +5275,13 @@ static void addMethodsToPool(Sema &S, ArrayRef<ObjCMethodDecl *> Methods, } void ASTReader::ReadMethodPool(Selector Sel) { - ReadMethodPoolVisitor Visitor(*this, Sel); + // Get the selector generation and update it to the current generation. + unsigned &Generation = SelectorGeneration[Sel]; + unsigned PriorGeneration = Generation; + Generation = CurrentGeneration; + + // Search for methods defined with this selector. + ReadMethodPoolVisitor Visitor(*this, Sel, PriorGeneration); ModuleMgr.visit(&ReadMethodPoolVisitor::visit, &Visitor); if (Visitor.getInstanceMethods().empty() && |