diff --git a/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp b/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp index 689aeda86a5..037beec3c34 100644 --- a/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp @@ -31,7 +31,7 @@ DwarfAccelTable::DwarfAccelTable(ArrayRef atomList) DwarfAccelTable::~DwarfAccelTable() {} -void DwarfAccelTable::AddName(StringRef Name, DIE *die, char Flags) { +void DwarfAccelTable::AddName(StringRef Name, const DIE *die, char Flags) { assert(Data.empty() && "Already finalized!"); // If the string is in the list already then add this die to the list // otherwise add a new one. diff --git a/lib/CodeGen/AsmPrinter/DwarfAccelTable.h b/lib/CodeGen/AsmPrinter/DwarfAccelTable.h index 7627313d28f..601e97c2620 100644 --- a/lib/CodeGen/AsmPrinter/DwarfAccelTable.h +++ b/lib/CodeGen/AsmPrinter/DwarfAccelTable.h @@ -165,10 +165,10 @@ private: // HashData[hash_data_count] public: struct HashDataContents { - DIE *Die; // Offsets + const DIE *Die; // Offsets char Flags; // Specific flags to output - HashDataContents(DIE *D, char Flags) : Die(D), Flags(Flags) {} + HashDataContents(const DIE *D, char Flags) : Die(D), Flags(Flags) {} #ifndef NDEBUG void print(raw_ostream &O) const { O << " Offset: " << Die->getOffset() << "\n"; @@ -241,7 +241,7 @@ private: public: DwarfAccelTable(ArrayRef); ~DwarfAccelTable(); - void AddName(StringRef, DIE *, char = 0); + void AddName(StringRef, const DIE *, char = 0); void FinalizeTable(AsmPrinter *, StringRef); void Emit(AsmPrinter *, MCSymbol *, DwarfUnits *); #ifndef NDEBUG diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 25b9c1da1c4..fbd7ce82283 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -900,8 +900,13 @@ DIE *CompileUnit::getOrCreateTypeDIE(const MDNode *TyNode) { assert(Ty.isDerivedType() && "Unknown kind of DIType"); constructTypeDIE(*TyDIE, DIDerivedType(Ty)); } - // If this is a named finished type then include it in the list of types - // for the accelerator tables. + + updateAcceleratorTables(Ty, TyDIE); + + return TyDIE; +} + +void CompileUnit::updateAcceleratorTables(DIType Ty, const DIE *TyDIE) { if (!Ty.getName().empty() && !Ty.isForwardDecl()) { bool IsImplementation = 0; if (Ty.isCompositeType()) { @@ -913,8 +918,6 @@ DIE *CompileUnit::getOrCreateTypeDIE(const MDNode *TyNode) { unsigned Flags = IsImplementation ? dwarf::DW_FLAG_type_implementation : 0; addAccelType(Ty.getName(), std::make_pair(TyDIE, Flags)); } - - return TyDIE; } /// addType - Add a new type attribute to the specified entity. @@ -946,27 +949,28 @@ void CompileUnit::addType(DIE *Entity, DIType Ty, dwarf::Attribute Attribute) { // DIE to the proper table while ensuring that the name that we're going // to reference is in the string table. We do this since the names we // add may not only be identical to the names in the DIE. -void CompileUnit::addAccelName(StringRef Name, DIE *Die) { +void CompileUnit::addAccelName(StringRef Name, const DIE *Die) { DU->getStringPoolEntry(Name); - std::vector &DIEs = AccelNames[Name]; + std::vector &DIEs = AccelNames[Name]; DIEs.push_back(Die); } -void CompileUnit::addAccelObjC(StringRef Name, DIE *Die) { +void CompileUnit::addAccelObjC(StringRef Name, const DIE *Die) { DU->getStringPoolEntry(Name); - std::vector &DIEs = AccelObjC[Name]; + std::vector &DIEs = AccelObjC[Name]; DIEs.push_back(Die); } -void CompileUnit::addAccelNamespace(StringRef Name, DIE *Die) { +void CompileUnit::addAccelNamespace(StringRef Name, const DIE *Die) { DU->getStringPoolEntry(Name); - std::vector &DIEs = AccelNamespace[Name]; + std::vector &DIEs = AccelNamespace[Name]; DIEs.push_back(Die); } -void CompileUnit::addAccelType(StringRef Name, std::pair Die) { +void CompileUnit::addAccelType(StringRef Name, + std::pair Die) { DU->getStringPoolEntry(Name); - std::vector > &DIEs = AccelTypes[Name]; + std::vector > &DIEs = AccelTypes[Name]; DIEs.push_back(Die); } diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h index e429921866f..02f4206e949 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h @@ -74,10 +74,10 @@ class CompileUnit { /// AccelNames - A map of names for the name accelerator table. /// - StringMap > AccelNames; - StringMap > AccelObjC; - StringMap > AccelNamespace; - StringMap > > AccelTypes; + StringMap > AccelNames; + StringMap > AccelObjC; + StringMap > AccelNamespace; + StringMap > > AccelTypes; /// DIEBlocks - A list of all the DIEBlocks in use. std::vector DIEBlocks; @@ -106,16 +106,16 @@ public: const StringMap &getGlobalNames() const { return GlobalNames; } const StringMap &getGlobalTypes() const { return GlobalTypes; } - const StringMap > &getAccelNames() const { + const StringMap > &getAccelNames() const { return AccelNames; } - const StringMap > &getAccelObjC() const { + const StringMap > &getAccelObjC() const { return AccelObjC; } - const StringMap > &getAccelNamespace() const { + const StringMap > &getAccelNamespace() const { return AccelNamespace; } - const StringMap > > & + const StringMap > > & getAccelTypes() const { return AccelTypes; } @@ -143,16 +143,16 @@ public: void addPubTypes(DISubprogram SP); /// addAccelName - Add a new name to the name accelerator table. - void addAccelName(StringRef Name, DIE *Die); + void addAccelName(StringRef Name, const DIE *Die); /// addAccelObjC - Add a new name to the ObjC accelerator table. - void addAccelObjC(StringRef Name, DIE *Die); + void addAccelObjC(StringRef Name, const DIE *Die); /// addAccelNamespace - Add a new name to the namespace accelerator table. - void addAccelNamespace(StringRef Name, DIE *Die); + void addAccelNamespace(StringRef Name, const DIE *Die); /// addAccelType - Add a new type to the type accelerator table. - void addAccelType(StringRef Name, std::pair Die); + void addAccelType(StringRef Name, std::pair Die); /// getDIE - Returns the debug information entry map slot for the /// specified debug variable. We delegate the request to DwarfDebug @@ -408,6 +408,10 @@ private: template T resolve(DIRef Ref) const { return DD->resolve(Ref); } + + /// If this is a named finished type then include it in the list of types for + /// the accelerator tables. + void updateAcceleratorTables(DIType Ty, const DIE *TyDIE); }; } // end llvm namespace diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 30fc94838cf..35f76047dba 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2247,16 +2247,17 @@ void DwarfDebug::emitAccelNames() { E = CUMap.end(); I != E; ++I) { CompileUnit *TheCU = I->second; - const StringMap > &Names = TheCU->getAccelNames(); - for (StringMap >::const_iterator GI = Names.begin(), - GE = Names.end(); + const StringMap > &Names = TheCU->getAccelNames(); + for (StringMap >::const_iterator + GI = Names.begin(), + GE = Names.end(); GI != GE; ++GI) { StringRef Name = GI->getKey(); - const std::vector &Entities = GI->second; - for (std::vector::const_iterator DI = Entities.begin(), - DE = Entities.end(); + const std::vector &Entities = GI->second; + for (std::vector::const_iterator DI = Entities.begin(), + DE = Entities.end(); DI != DE; ++DI) - AT.AddName(Name, (*DI)); + AT.AddName(Name, *DI); } } @@ -2279,16 +2280,17 @@ void DwarfDebug::emitAccelObjC() { E = CUMap.end(); I != E; ++I) { CompileUnit *TheCU = I->second; - const StringMap > &Names = TheCU->getAccelObjC(); - for (StringMap >::const_iterator GI = Names.begin(), - GE = Names.end(); + const StringMap > &Names = TheCU->getAccelObjC(); + for (StringMap >::const_iterator + GI = Names.begin(), + GE = Names.end(); GI != GE; ++GI) { StringRef Name = GI->getKey(); - const std::vector &Entities = GI->second; - for (std::vector::const_iterator DI = Entities.begin(), - DE = Entities.end(); + const std::vector &Entities = GI->second; + for (std::vector::const_iterator DI = Entities.begin(), + DE = Entities.end(); DI != DE; ++DI) - AT.AddName(Name, (*DI)); + AT.AddName(Name, *DI); } } @@ -2310,16 +2312,18 @@ void DwarfDebug::emitAccelNamespaces() { E = CUMap.end(); I != E; ++I) { CompileUnit *TheCU = I->second; - const StringMap > &Names = TheCU->getAccelNamespace(); - for (StringMap >::const_iterator GI = Names.begin(), - GE = Names.end(); + const StringMap > &Names = + TheCU->getAccelNamespace(); + for (StringMap >::const_iterator + GI = Names.begin(), + GE = Names.end(); GI != GE; ++GI) { StringRef Name = GI->getKey(); - const std::vector &Entities = GI->second; - for (std::vector::const_iterator DI = Entities.begin(), - DE = Entities.end(); + const std::vector &Entities = GI->second; + for (std::vector::const_iterator DI = Entities.begin(), + DE = Entities.end(); DI != DE; ++DI) - AT.AddName(Name, (*DI)); + AT.AddName(Name, *DI); } } @@ -2347,19 +2351,21 @@ void DwarfDebug::emitAccelTypes() { E = CUMap.end(); I != E; ++I) { CompileUnit *TheCU = I->second; - const StringMap > > &Names = + const StringMap > > &Names = TheCU->getAccelTypes(); - for (StringMap > >::const_iterator + for (StringMap< + std::vector > >::const_iterator GI = Names.begin(), GE = Names.end(); GI != GE; ++GI) { StringRef Name = GI->getKey(); - const std::vector > &Entities = GI->second; - for (std::vector >::const_iterator + const std::vector > &Entities = + GI->second; + for (std::vector >::const_iterator DI = Entities.begin(), DE = Entities.end(); DI != DE; ++DI) - AT.AddName(Name, (*DI).first, (*DI).second); + AT.AddName(Name, DI->first, DI->second); } }