[llvm] r273431 - [codeview] Remove ClassInfoMap
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 22 09:06:43 PDT 2016
Author: rnk
Date: Wed Jun 22 11:06:42 2016
New Revision: 273431
URL: http://llvm.org/viewvc/llvm-project?rev=273431&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=273431&r1=273430&r2=273431&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Wed Jun 22 11:06:42 2016
@@ -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(Cl
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<DICompositeType>(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>()});
- ClassInfo *Info = nullptr;
- {
- std::unique_ptr<ClassInfo> &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::collectClassIn
// 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<DIDerivedType>(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::collectClassIn
}
// Skip other unrecognized kinds of elements.
}
-
- return *Info;
+ return Info;
}
TypeIndex CodeViewDebug::lowerTypeClass(const DICompositeType *Ty) {
@@ -1466,7 +1455,7 @@ CodeViewDebug::lowerRecordFieldList(cons
// 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.
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h?rev=273431&r1=273430&r2=273431&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h Wed Jun 22 11:06:42 2016
@@ -150,8 +150,6 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDe
/// always looked up in the normal TypeIndices map.
DenseMap<const DICompositeType *, codeview::TypeIndex> CompleteTypeIndices;
- /// Map from DICompositeType* to class info.
- DenseMap<const DICompositeType *, std::unique_ptr<ClassInfo>> 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 CodeViewDe
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
More information about the llvm-commits
mailing list