[cfe-commits] r114518 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Tue Sep 21 17:42:30 PDT 2010
Author: cornedbee
Date: Tue Sep 21 19:42:30 2010
New Revision: 114518
URL: http://llvm.org/viewvc/llvm-project?rev=114518&view=rev
Log:
Only preload SLocEntries after the entire PCH chain was loaded.
Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=114518&r1=114517&r2=114518&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Sep 21 19:42:30 2010
@@ -228,6 +228,9 @@
/// AST file.
const uint32_t *SLocOffsets;
+ /// \brief The next SourceLocation offset after reading this file.
+ unsigned NextOffset;
+
// === Identifiers ===
/// \brief The number of identifiers in this AST file.
@@ -326,6 +329,9 @@
/// That is, the entry I was created with -include-pch I+1.
llvm::SmallVector<PerFileData*, 2> Chain;
+ /// \brief SLocEntries that we're going to preload.
+ llvm::SmallVector<uint64_t, 64> PreloadSLocEntries;
+
/// \brief Types that have already been loaded from the chain.
///
/// When the pointer at index I is non-NULL, the type with
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=114518&r1=114517&r2=114518&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Sep 21 19:42:30 2010
@@ -1863,11 +1863,13 @@
TotalNumMethodPoolEntries += Record[1];
break;
- case REFERENCED_SELECTOR_POOL: {
- ReferencedSelectorsData.insert(ReferencedSelectorsData.end(),
- Record.begin(), Record.end());
+ case REFERENCED_SELECTOR_POOL:
+ if (ReferencedSelectorsData.empty())
+ ReferencedSelectorsData.swap(Record);
+ else
+ ReferencedSelectorsData.insert(ReferencedSelectorsData.end(),
+ Record.begin(), Record.end());
break;
- }
case PP_COUNTER_VALUE:
if (!Record.empty() && Listener)
@@ -1877,19 +1879,15 @@
case SOURCE_LOCATION_OFFSETS:
F.SLocOffsets = (const uint32_t *)BlobStart;
F.LocalNumSLocEntries = Record[0];
- // We cannot delay this until the entire chain is loaded, because then
- // source location preloads would also have to be delayed.
- // FIXME: Is there a reason not to do that?
- TotalNumSLocEntries += F.LocalNumSLocEntries;
- SourceMgr.PreallocateSLocEntries(this, TotalNumSLocEntries, Record[1]);
+ F.NextOffset = Record[1];
break;
case SOURCE_LOCATION_PRELOADS:
- for (unsigned I = 0, N = Record.size(); I != N; ++I) {
- ASTReadResult Result = ReadSLocEntryRecord(Record[I]);
- if (Result != Success)
- return Result;
- }
+ if (PreloadSLocEntries.empty())
+ PreloadSLocEntries.swap(Record);
+ else
+ PreloadSLocEntries.insert(PreloadSLocEntries.end(),
+ Record.begin(), Record.end());
break;
case STAT_CACHE: {
@@ -1996,11 +1994,12 @@
// Here comes stuff that we only do once the entire chain is loaded.
- // Allocate space for loaded identifiers, decls and types.
+ // Allocate space for loaded slocentries, identifiers, decls and types.
unsigned TotalNumIdentifiers = 0, TotalNumTypes = 0, TotalNumDecls = 0,
TotalNumPreallocatedPreprocessingEntities = 0, TotalNumMacroDefs = 0,
TotalNumSelectors = 0;
for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
+ TotalNumSLocEntries += Chain[I]->LocalNumSLocEntries;
TotalNumIdentifiers += Chain[I]->LocalNumIdentifiers;
TotalNumTypes += Chain[I]->LocalNumTypes;
TotalNumDecls += Chain[I]->LocalNumDecls;
@@ -2009,6 +2008,8 @@
TotalNumMacroDefs += Chain[I]->LocalNumMacroDefinitions;
TotalNumSelectors += Chain[I]->LocalNumSelectors;
}
+ SourceMgr.PreallocateSLocEntries(this, TotalNumSLocEntries,
+ Chain.front()->NextOffset);
IdentifiersLoaded.resize(TotalNumIdentifiers);
TypesLoaded.resize(TotalNumTypes);
DeclsLoaded.resize(TotalNumDecls);
@@ -2024,6 +2025,12 @@
}
}
SelectorsLoaded.resize(TotalNumSelectors);
+ // Preload SLocEntries.
+ for (unsigned I = 0, N = PreloadSLocEntries.size(); I != N; ++I) {
+ ASTReadResult Result = ReadSLocEntryRecord(PreloadSLocEntries[I]);
+ if (Result != Success)
+ return Result;
+ }
// Check the predefines buffers.
if (!DisableValidation && CheckPredefinesBuffers())
More information about the cfe-commits
mailing list