Don't introduce a local -> global mapping for CXXBaseSpecifiers. The

IDs will never cross module boundaries, since they're tied to the
CXXDefinitionData, so just use a local mapping throughout. Eliminate
the global -> local tables and supporting data.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136847 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Douglas Gregor 2011-08-04 00:01:48 +00:00
Родитель 8d28897e32
Коммит e92b8a1dbb
4 изменённых файлов: 20 добавлений и 44 удалений

Просмотреть файл

@ -377,9 +377,6 @@ public:
/// indexed by the C++ base specifier set ID (-1). /// indexed by the C++ base specifier set ID (-1).
const uint32_t *CXXBaseSpecifiersOffsets; const uint32_t *CXXBaseSpecifiersOffsets;
/// \brief Base base specifier ID for base specifiers local to this module.
serialization::CXXBaseSpecifiersID BaseCXXBaseSpecifiersID;
// === Types === // === Types ===
/// \brief The number of types in this AST file. /// \brief The number of types in this AST file.
@ -723,14 +720,6 @@ private:
/// added to the global preprocessing entitiy ID to produce a local ID. /// added to the global preprocessing entitiy ID to produce a local ID.
GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap; GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap;
typedef ContinuousRangeMap<serialization::CXXBaseSpecifiersID, Module *, 4>
GlobalCXXBaseSpecifiersMapType;
/// \brief Mapping from global CXX base specifier IDs to the module in which
/// the CXX base specifier resides along with the offset that should be added
/// to the global CXX base specifer ID to produce a local ID.
GlobalCXXBaseSpecifiersMapType GlobalCXXBaseSpecifiersMap;
/// \name CodeGen-relevant special data /// \name CodeGen-relevant special data
/// \brief Fields containing data that is relevant to CodeGen. /// \brief Fields containing data that is relevant to CodeGen.
//@{ //@{
@ -1034,7 +1023,9 @@ private:
void LoadedDecl(unsigned Index, Decl *D); void LoadedDecl(unsigned Index, Decl *D);
Decl *ReadDeclRecord(serialization::DeclID ID); Decl *ReadDeclRecord(serialization::DeclID ID);
RecordLocation DeclCursorForID(serialization::DeclID ID); RecordLocation DeclCursorForID(serialization::DeclID ID);
RecordLocation getLocalBitOffset(uint64_t GlobalOffset); RecordLocation getLocalBitOffset(uint64_t GlobalOffset);
uint64_t getGlobalBitOffset(Module &M, uint32_t LocalOffset);
void PassInterestingDeclsToConsumer(); void PassInterestingDeclsToConsumer();
@ -1292,9 +1283,10 @@ public:
return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I))); return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I)));
} }
/// \brief Resolve a CXXBaseSpecifiers ID into an offset into the chain /// \brief Read a CXXBaseSpecifiers ID form the given record and
/// of loaded AST files. /// return its global bit offset.
uint64_t GetCXXBaseSpecifiersOffset(serialization::CXXBaseSpecifiersID ID); uint64_t readCXXBaseSpecifiers(Module &M, const RecordData &Record,
unsigned &Idx);
virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset); virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset);

Просмотреть файл

@ -2336,7 +2336,6 @@ ASTReader::ReadASTBlock(Module &F) {
uint32_t MacroDefinitionIDOffset = io::ReadUnalignedLE32(Data); uint32_t MacroDefinitionIDOffset = io::ReadUnalignedLE32(Data);
uint32_t SelectorIDOffset = io::ReadUnalignedLE32(Data); uint32_t SelectorIDOffset = io::ReadUnalignedLE32(Data);
uint32_t DeclIDOffset = io::ReadUnalignedLE32(Data); uint32_t DeclIDOffset = io::ReadUnalignedLE32(Data);
uint32_t CXXBaseSpecifiersIDOffset = io::ReadUnalignedLE32(Data);
uint32_t TypeIndexOffset = io::ReadUnalignedLE32(Data); uint32_t TypeIndexOffset = io::ReadUnalignedLE32(Data);
// Source location offset is mapped to OM->SLocEntryBaseOffset. // Source location offset is mapped to OM->SLocEntryBaseOffset.
@ -2354,8 +2353,6 @@ ASTReader::ReadASTBlock(Module &F) {
DeclRemap.insert(std::make_pair(DeclIDOffset, DeclRemap.insert(std::make_pair(DeclIDOffset,
OM->BaseDeclID - DeclIDOffset)); OM->BaseDeclID - DeclIDOffset));
(void)CXXBaseSpecifiersIDOffset;
TypeRemap.insert(std::make_pair(TypeIndexOffset, TypeRemap.insert(std::make_pair(TypeIndexOffset,
OM->BaseTypeIndex - TypeIndexOffset)); OM->BaseTypeIndex - TypeIndexOffset));
} }
@ -2539,10 +2536,6 @@ ASTReader::ReadASTBlock(Module &F) {
F.LocalNumCXXBaseSpecifiers = Record[0]; F.LocalNumCXXBaseSpecifiers = Record[0];
F.CXXBaseSpecifiersOffsets = (const uint32_t *)BlobStart; F.CXXBaseSpecifiersOffsets = (const uint32_t *)BlobStart;
F.BaseCXXBaseSpecifiersID = getTotalNumCXXBaseSpecifiers();
GlobalCXXBaseSpecifiersMap.insert(
std::make_pair(getTotalNumCXXBaseSpecifiers() + 1, &F));
NumCXXBaseSpecifiersLoaded += F.LocalNumCXXBaseSpecifiers; NumCXXBaseSpecifiersLoaded += F.LocalNumCXXBaseSpecifiers;
break; break;
} }
@ -4091,20 +4084,13 @@ Decl *ASTReader::GetExternalDecl(uint32_t ID) {
return GetDecl(ID); return GetDecl(ID);
} }
uint64_t uint64_t ASTReader::readCXXBaseSpecifiers(Module &M, const RecordData &Record,
ASTReader::GetCXXBaseSpecifiersOffset(serialization::CXXBaseSpecifiersID ID) { unsigned &Idx){
if (ID == 0) if (Idx >= Record.size())
return 0; return 0;
GlobalCXXBaseSpecifiersMapType::iterator I =
GlobalCXXBaseSpecifiersMap.find(ID);
assert (I != GlobalCXXBaseSpecifiersMap.end() &&
"Corrupted global CXX base specifiers map");
Module *M = I->second; unsigned LocalID = Record[Idx++];
return M->CXXBaseSpecifiersOffsets[ID - 1 - M->BaseCXXBaseSpecifiersID] + return getGlobalBitOffset(M, M.CXXBaseSpecifiersOffsets[LocalID - 1]);
M->GlobalBitOffset;
} }
CXXBaseSpecifier *ASTReader::GetExternalCXXBaseSpecifiers(uint64_t Offset) { CXXBaseSpecifier *ASTReader::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
@ -4438,7 +4424,6 @@ void ASTReader::dump() {
dumpModuleIDMap("Global source location entry map", GlobalSLocEntryMap); dumpModuleIDMap("Global source location entry map", GlobalSLocEntryMap);
dumpModuleIDMap("Global type map", GlobalTypeMap); dumpModuleIDMap("Global type map", GlobalTypeMap);
dumpModuleIDMap("Global declaration map", GlobalDeclMap); dumpModuleIDMap("Global declaration map", GlobalDeclMap);
dumpModuleIDMap("Global C++ base specifiers map", GlobalCXXBaseSpecifiersMap);
dumpModuleIDMap("Global identifier map", GlobalIdentifierMap); dumpModuleIDMap("Global identifier map", GlobalIdentifierMap);
dumpModuleIDMap("Global selector map", GlobalSelectorMap); dumpModuleIDMap("Global selector map", GlobalSelectorMap);
dumpModuleIDMap("Global macro definition map", GlobalMacroDefinitionMap); dumpModuleIDMap("Global macro definition map", GlobalMacroDefinitionMap);
@ -5555,7 +5540,6 @@ Module::Module(ModuleKind Kind)
SelectorLookupTableData(0), SelectorLookupTable(0), LocalNumDecls(0), SelectorLookupTableData(0), SelectorLookupTable(0), LocalNumDecls(0),
DeclOffsets(0), BaseDeclID(0), DeclOffsets(0), BaseDeclID(0),
LocalNumCXXBaseSpecifiers(0), CXXBaseSpecifiersOffsets(0), LocalNumCXXBaseSpecifiers(0), CXXBaseSpecifiersOffsets(0),
BaseCXXBaseSpecifiersID(0),
LocalNumTypes(0), TypeOffsets(0), BaseTypeIndex(0), StatCache(0), LocalNumTypes(0), TypeOffsets(0), BaseTypeIndex(0), StatCache(0),
NumPreallocatedPreprocessingEntities(0) NumPreallocatedPreprocessingEntities(0)
{} {}

Просмотреть файл

@ -889,10 +889,10 @@ void ASTDeclReader::ReadCXXDefinitionData(
Data.NumBases = Record[Idx++]; Data.NumBases = Record[Idx++];
if (Data.NumBases) if (Data.NumBases)
Data.Bases = Reader.GetCXXBaseSpecifiersOffset(Record[Idx++]); Data.Bases = Reader.readCXXBaseSpecifiers(F, Record, Idx);
Data.NumVBases = Record[Idx++]; Data.NumVBases = Record[Idx++];
if (Data.NumVBases) if (Data.NumVBases)
Data.VBases = Reader.GetCXXBaseSpecifiersOffset(Record[Idx++]); Data.VBases = Reader.readCXXBaseSpecifiers(F, Record, Idx);
Reader.ReadUnresolvedSet(F, Data.Conversions, Record, Idx); Reader.ReadUnresolvedSet(F, Data.Conversions, Record, Idx);
Reader.ReadUnresolvedSet(F, Data.VisibleConversions, Record, Idx); Reader.ReadUnresolvedSet(F, Data.VisibleConversions, Record, Idx);
@ -1419,6 +1419,10 @@ ASTReader::RecordLocation ASTReader::getLocalBitOffset(uint64_t GlobalOffset) {
return RecordLocation(I->second, GlobalOffset - I->second->GlobalBitOffset); return RecordLocation(I->second, GlobalOffset - I->second->GlobalBitOffset);
} }
uint64_t ASTReader::getGlobalBitOffset(Module &M, uint32_t LocalOffset) {
return LocalOffset + M.GlobalBitOffset;
}
void ASTDeclReader::attachPreviousDecl(Decl *D, Decl *previous) { void ASTDeclReader::attachPreviousDecl(Decl *D, Decl *previous) {
assert(D && previous); assert(D && previous);
if (TagDecl *TD = dyn_cast<TagDecl>(D)) { if (TagDecl *TD = dyn_cast<TagDecl>(D)) {

Просмотреть файл

@ -1928,7 +1928,7 @@ void ASTWriter::WriteCXXBaseSpecifiersOffsets() {
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
unsigned BaseSpecifierOffsetAbbrev = Stream.EmitAbbrev(Abbrev); unsigned BaseSpecifierOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
// Write the selector offsets table. // Write the base specifier offsets table.
Record.clear(); Record.clear();
Record.push_back(CXX_BASE_SPECIFIER_OFFSETS); Record.push_back(CXX_BASE_SPECIFIER_OFFSETS);
Record.push_back(CXXBaseSpecifiersOffsets.size()); Record.push_back(CXXBaseSpecifiersOffsets.size());
@ -2752,7 +2752,7 @@ ASTWriter::ASTWriter(llvm::BitstreamWriter &Stream)
CollectedStmts(&StmtsToEmit), CollectedStmts(&StmtsToEmit),
NumStatements(0), NumMacros(0), NumLexicalDeclContexts(0), NumStatements(0), NumMacros(0), NumLexicalDeclContexts(0),
NumVisibleDeclContexts(0), NumVisibleDeclContexts(0),
FirstCXXBaseSpecifiersID(1), NextCXXBaseSpecifiersID(1), NextCXXBaseSpecifiersID(1),
DeclParmVarAbbrev(0), DeclContextLexicalAbbrev(0), DeclParmVarAbbrev(0), DeclContextLexicalAbbrev(0),
DeclContextVisibleLookupAbbrev(0), UpdateVisibleAbbrev(0), DeclContextVisibleLookupAbbrev(0), UpdateVisibleAbbrev(0),
DeclRefExprAbbrev(0), CharacterLiteralAbbrev(0), DeclRefExprAbbrev(0), CharacterLiteralAbbrev(0),
@ -3077,7 +3077,6 @@ void ASTWriter::WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
io::Emit32(Out, (*M)->BaseMacroDefinitionID); io::Emit32(Out, (*M)->BaseMacroDefinitionID);
io::Emit32(Out, (*M)->BaseSelectorID); io::Emit32(Out, (*M)->BaseSelectorID);
io::Emit32(Out, (*M)->BaseDeclID); io::Emit32(Out, (*M)->BaseDeclID);
io::Emit32(Out, (*M)->BaseCXXBaseSpecifiersID);
io::Emit32(Out, (*M)->BaseTypeIndex); io::Emit32(Out, (*M)->BaseTypeIndex);
} }
} }
@ -3879,7 +3878,7 @@ void ASTWriter::FlushCXXBaseSpecifiers() {
Record.clear(); Record.clear();
// Record the offset of this base-specifier set. // Record the offset of this base-specifier set.
unsigned Index = CXXBaseSpecifiersToWrite[I].ID - FirstCXXBaseSpecifiersID; unsigned Index = CXXBaseSpecifiersToWrite[I].ID - 1;
if (Index == CXXBaseSpecifiersOffsets.size()) if (Index == CXXBaseSpecifiersOffsets.size())
CXXBaseSpecifiersOffsets.push_back(Stream.GetCurrentBitNo()); CXXBaseSpecifiersOffsets.push_back(Stream.GetCurrentBitNo());
else { else {
@ -3998,7 +3997,6 @@ void ASTWriter::ReaderInitialized(ASTReader *Reader) {
FirstIdentID == NextIdentID && FirstIdentID == NextIdentID &&
FirstSelectorID == NextSelectorID && FirstSelectorID == NextSelectorID &&
FirstMacroID == NextMacroID && FirstMacroID == NextMacroID &&
FirstCXXBaseSpecifiersID == NextCXXBaseSpecifiersID &&
"Setting chain after writing has started."); "Setting chain after writing has started.");
Chain = Reader; Chain = Reader;
@ -4008,13 +4006,11 @@ void ASTWriter::ReaderInitialized(ASTReader *Reader) {
FirstIdentID += Chain->getTotalNumIdentifiers(); FirstIdentID += Chain->getTotalNumIdentifiers();
FirstSelectorID += Chain->getTotalNumSelectors(); FirstSelectorID += Chain->getTotalNumSelectors();
FirstMacroID += Chain->getTotalNumMacroDefinitions(); FirstMacroID += Chain->getTotalNumMacroDefinitions();
FirstCXXBaseSpecifiersID += Chain->getTotalNumCXXBaseSpecifiers();
NextDeclID = FirstDeclID; NextDeclID = FirstDeclID;
NextTypeID = FirstTypeID; NextTypeID = FirstTypeID;
NextIdentID = FirstIdentID; NextIdentID = FirstIdentID;
NextSelectorID = FirstSelectorID; NextSelectorID = FirstSelectorID;
NextMacroID = FirstMacroID; NextMacroID = FirstMacroID;
NextCXXBaseSpecifiersID = FirstCXXBaseSpecifiersID;
} }
void ASTWriter::IdentifierRead(IdentID ID, IdentifierInfo *II) { void ASTWriter::IdentifierRead(IdentID ID, IdentifierInfo *II) {