From 1ab7eac84bf2a63a6cdc9788f12c2c44a84abb6c Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 22 Jun 2016 16:06:42 +0000 Subject: [PATCH] [codeview] Remove ClassInfoMap From a design perspective, complete record type emission should not depend on information from other complete record types. Currently this map is unused, and needlessly accumulates data throughout compilation. llvm-svn: 273431 --- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 35 +++++++------------ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h | 4 +-- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index 9163e3b4c157..31f0872a3010 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -1337,7 +1337,6 @@ void CodeViewDebug::clear() { GlobalUDTs.clear(); TypeIndices.clear(); CompleteTypeIndices.clear(); - ClassInfoMap.clear(); } void CodeViewDebug::collectMemberInfo(ClassInfo &Info, @@ -1346,29 +1345,20 @@ void CodeViewDebug::collectMemberInfo(ClassInfo &Info, Info.Members.push_back({DDTy, 0}); return; } - // Member with no name, must be nested structure/union, collects its memebers + // An unnamed member must represent a nested struct or union. Add all the + // indirect fields to the current record. assert((DDTy->getOffsetInBits() % 8) == 0 && "Unnamed bitfield member!"); - unsigned offset = DDTy->getOffsetInBits() / 8; + unsigned Offset = DDTy->getOffsetInBits() / 8; const DIType *Ty = DDTy->getBaseType().resolve(); const DICompositeType *DCTy = cast(Ty); - ClassInfo &NestedInfo = collectClassInfo(DCTy); - ClassInfo::MemberList &Members = NestedInfo.Members; - for (unsigned i = 0, e = Members.size(); i != e; ++i) + ClassInfo NestedInfo = collectClassInfo(DCTy); + for (const ClassInfo::MemberInfo &IndirectField : NestedInfo.Members) Info.Members.push_back( - {Members[i].MemberTypeNode, Members[i].BaseOffset + offset}); + {IndirectField.MemberTypeNode, IndirectField.BaseOffset + Offset}); } -ClassInfo &CodeViewDebug::collectClassInfo(const DICompositeType *Ty) { - auto Insertion = ClassInfoMap.insert({Ty, std::unique_ptr()}); - ClassInfo *Info = nullptr; - { - std::unique_ptr &InfoEntry = Insertion.first->second; - if (!Insertion.second) - return *InfoEntry; - InfoEntry.reset(new ClassInfo()); - Info = InfoEntry.get(); - } - +ClassInfo CodeViewDebug::collectClassInfo(const DICompositeType *Ty) { + ClassInfo Info; // Add elements to structure type. DINodeArray Elements = Ty->getElements(); for (auto *Element : Elements) { @@ -1380,10 +1370,10 @@ ClassInfo &CodeViewDebug::collectClassInfo(const DICompositeType *Ty) { // Non-virtual methods does not need the introduced marker. // Set it to false. bool Introduced = false; - Info->Methods[SP->getRawName()].push_back({SP, Introduced}); + Info.Methods[SP->getRawName()].push_back({SP, Introduced}); } else if (auto *DDTy = dyn_cast(Element)) { if (DDTy->getTag() == dwarf::DW_TAG_member) - collectMemberInfo(*Info, DDTy); + collectMemberInfo(Info, DDTy); else if (DDTy->getTag() == dwarf::DW_TAG_inheritance) { // FIXME: collect class info from inheritance. } else if (DDTy->getTag() == dwarf::DW_TAG_friend) { @@ -1396,8 +1386,7 @@ ClassInfo &CodeViewDebug::collectClassInfo(const DICompositeType *Ty) { } // Skip other unrecognized kinds of elements. } - - return *Info; + return Info; } TypeIndex CodeViewDebug::lowerTypeClass(const DICompositeType *Ty) { @@ -1466,7 +1455,7 @@ CodeViewDebug::lowerRecordFieldList(const DICompositeType *Ty) { // contributes to this count, even though the overload group is a single field // list record. unsigned MemberCount = 0; - ClassInfo &Info = collectClassInfo(Ty); + ClassInfo Info = collectClassInfo(Ty); FieldListRecordBuilder Fields; // Create members. diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h index 98499b934aff..be8d6cea024c 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h @@ -150,8 +150,6 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { /// always looked up in the normal TypeIndices map. DenseMap CompleteTypeIndices; - /// Map from DICompositeType* to class info. - DenseMap> ClassInfoMap; const DISubprogram *CurrentSubprogram = nullptr; // The UDTs we have seen while processing types; each entry is a pair of type @@ -249,7 +247,7 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { codeview::TypeIndex lowerCompleteTypeUnion(const DICompositeType *Ty); void collectMemberInfo(ClassInfo &Info, const DIDerivedType *DDTy); - ClassInfo &collectClassInfo(const DICompositeType *Ty); + ClassInfo collectClassInfo(const DICompositeType *Ty); /// Common record member lowering functionality for record types, which are /// structs, classes, and unions. Returns the field list index and the member