forked from OSchip/llvm-project
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. llvm-svn: 173056
This commit is contained in:
parent
a4fe1c13c0
commit
d8666e49cc
|
@ -1515,11 +1515,22 @@ public:
|
|||
/// \brief Report a diagnostic.
|
||||
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID);
|
||||
|
||||
IdentifierInfo *DecodeIdentifierInfo(serialization::IdentifierID ID);
|
||||
/// \brief Given the global ID for an identifier, retrieve the
|
||||
/// corresponding identifier information.
|
||||
///
|
||||
/// \param ID The global ID.
|
||||
///
|
||||
/// \param StartOutOfDate If true, don't actually read the identifier
|
||||
/// contents (macro definition, etc.). Instead, put the identifier in the
|
||||
/// "out-of-date" state to its contents to be loaded later.
|
||||
IdentifierInfo *DecodeIdentifierInfo(serialization::IdentifierID ID,
|
||||
bool StartOutOfDate = false);
|
||||
|
||||
IdentifierInfo *GetIdentifierInfo(ModuleFile &M, const RecordData &Record,
|
||||
unsigned &Idx) {
|
||||
return DecodeIdentifierInfo(getGlobalIdentifierID(M, Record[Idx++]));
|
||||
unsigned &Idx,
|
||||
bool StartOutOfDate = false) {
|
||||
return DecodeIdentifierInfo(getGlobalIdentifierID(M, Record[Idx++]),
|
||||
StartOutOfDate);
|
||||
}
|
||||
|
||||
virtual IdentifierInfo *GetIdentifier(serialization::IdentifierID ID) {
|
||||
|
@ -1529,7 +1540,8 @@ public:
|
|||
return DecodeIdentifierInfo(ID);
|
||||
}
|
||||
|
||||
IdentifierInfo *getLocalIdentifier(ModuleFile &M, unsigned LocalID);
|
||||
IdentifierInfo *getLocalIdentifier(ModuleFile &M, unsigned LocalID,
|
||||
bool StartOutOfDate = false);
|
||||
|
||||
serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M,
|
||||
unsigned LocalID);
|
||||
|
|
|
@ -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;
|
||||
|
||||
StringRef Name(Str, StrLen);
|
||||
if (StartOutOfDate) {
|
||||
IdentifiersLoaded[ID] = &PP.getIdentifierTable().getOwn(Name);
|
||||
IdentifiersLoaded[ID]->setOutOfDate(true);
|
||||
} else {
|
||||
IdentifiersLoaded[ID]
|
||||
= &PP.getIdentifierTable().get(StringRef(Str, StrLen));
|
||||
= &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:
|
||||
|
|
Loading…
Reference in New Issue