summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-06-22 16:06:42 +0000
committerReid Kleckner <rnk@google.com>2016-06-22 16:06:42 +0000
commit1ab7eac84bf2a63a6cdc9788f12c2c44a84abb6c (patch)
tree40d2ad4c8e3490f2fa73fe6b47f39fa135562b9d
parent69317f2ec2eba8c1a0f79e4688217f6fab262b8a (diff)
downloadbcm5719-llvm-1ab7eac84bf2a63a6cdc9788f12c2c44a84abb6c.tar.gz
bcm5719-llvm-1ab7eac84bf2a63a6cdc9788f12c2c44a84abb6c.zip
[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
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp35
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h4
2 files changed, 13 insertions, 26 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 9163e3b4c15..31f0872a301 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<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::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<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::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 98499b934af..be8d6cea024 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<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 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
OpenPOWER on IntegriCloud