aboutsummaryrefslogtreecommitdiff
path: root/lib/Serialization/ASTReader.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2013-01-21 16:47:11 +0000
committerDouglas Gregor <dgregor@apple.com>2013-01-21 16:47:11 +0000
commitc44cc015a8525e9b7d81a1f1cc1b6e827cfe6762 (patch)
treeaa17d2b4f1804c4848cba0d48bf8ea3a8299cff8 /lib/Serialization/ASTReader.cpp
parent2f1ac41a6d8d202dcc39ab8eb56ccea823dc062e (diff)
When loading an identifier from an AST file solely for the purpose of
forming the identifier, e.g., as part of a selector or a declaration name, don't actually deserialize any information about the identifier. Instead, simply mark it "out-of-date" and we'll load the the information on demand. 2% speedup on the modules testcase I'm looking at; should also help PCH. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173056 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTReader.cpp')
-rw-r--r--lib/Serialization/ASTReader.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index db850f3f83..e360d8dde2 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -398,7 +398,7 @@ ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) {
SelectorTable &SelTable = Reader.getContext().Selectors;
unsigned N = ReadUnalignedLE16(d);
IdentifierInfo *FirstII
- = Reader.getLocalIdentifier(F, ReadUnalignedLE32(d));
+ = Reader.getLocalIdentifier(F, ReadUnalignedLE32(d), true);
if (N == 0)
return SelTable.getNullarySelector(FirstII);
else if (N == 1)
@@ -407,7 +407,7 @@ ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) {
SmallVector<IdentifierInfo *, 16> Args;
Args.push_back(FirstII);
for (unsigned I = 1; I != N; ++I)
- Args.push_back(Reader.getLocalIdentifier(F, ReadUnalignedLE32(d)));
+ Args.push_back(Reader.getLocalIdentifier(F, ReadUnalignedLE32(d), true));
return SelTable.getSelector(N, Args.data());
}
@@ -6038,7 +6038,8 @@ ASTReader::SetGloballyVisibleDecls(IdentifierInfo *II,
}
}
-IdentifierInfo *ASTReader::DecodeIdentifierInfo(IdentifierID ID) {
+IdentifierInfo *ASTReader::DecodeIdentifierInfo(IdentifierID ID,
+ bool StartOutOfDate) {
if (ID == 0)
return 0;
@@ -6063,8 +6064,15 @@ IdentifierInfo *ASTReader::DecodeIdentifierInfo(IdentifierID ID) {
const unsigned char *StrLenPtr = (const unsigned char*) Str - 2;
unsigned StrLen = (((unsigned) StrLenPtr[0])
| (((unsigned) StrLenPtr[1]) << 8)) - 1;
- IdentifiersLoaded[ID]
- = &PP.getIdentifierTable().get(StringRef(Str, StrLen));
+
+ StringRef Name(Str, StrLen);
+ if (StartOutOfDate) {
+ IdentifiersLoaded[ID] = &PP.getIdentifierTable().getOwn(Name);
+ IdentifiersLoaded[ID]->setOutOfDate(true);
+ } else {
+ IdentifiersLoaded[ID]
+ = &PP.getIdentifierTable().get(Name);
+ }
if (DeserializationListener)
DeserializationListener->IdentifierRead(ID + 1, IdentifiersLoaded[ID]);
}
@@ -6072,8 +6080,10 @@ IdentifierInfo *ASTReader::DecodeIdentifierInfo(IdentifierID ID) {
return IdentifiersLoaded[ID];
}
-IdentifierInfo *ASTReader::getLocalIdentifier(ModuleFile &M, unsigned LocalID) {
- return DecodeIdentifierInfo(getGlobalIdentifierID(M, LocalID));
+IdentifierInfo *ASTReader::getLocalIdentifier(ModuleFile &M, unsigned LocalID,
+ bool StartOutOfDate) {
+ return DecodeIdentifierInfo(getGlobalIdentifierID(M, LocalID),
+ StartOutOfDate);
}
IdentifierID ASTReader::getGlobalIdentifierID(ModuleFile &M, unsigned LocalID) {
@@ -6209,7 +6219,7 @@ ASTReader::ReadDeclarationName(ModuleFile &F,
DeclarationName::NameKind Kind = (DeclarationName::NameKind)Record[Idx++];
switch (Kind) {
case DeclarationName::Identifier:
- return DeclarationName(GetIdentifierInfo(F, Record, Idx));
+ return DeclarationName(GetIdentifierInfo(F, Record, Idx, true));
case DeclarationName::ObjCZeroArgSelector:
case DeclarationName::ObjCOneArgSelector: