summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/CodeView
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-05-25 21:15:37 +0000
committerZachary Turner <zturner@google.com>2017-05-25 21:15:37 +0000
commit7f97c362a4640d2ce8481b091b8f5df495b13fda (patch)
tree880d82ba85df0a01d62377ee145f02fda6483ff9 /llvm/lib/DebugInfo/CodeView
parent95c625ecc9067f7215f476f44f01cb0cc0c24ba8 (diff)
downloadbcm5719-llvm-7f97c362a4640d2ce8481b091b8f5df495b13fda.tar.gz
bcm5719-llvm-7f97c362a4640d2ce8481b091b8f5df495b13fda.zip
[CodeView Type Merging] Don't keep re-allocating temp serializer.
Previously, every time we wanted to serialize a field list record, we would create a new copy of FieldListRecordBuilder, which would in turn create a temporary instance of TypeSerializer, which itself had a std::vector<> that was about 128K in size. So this 128K allocation was happening every time. We can re-use the same instance over and over, we just have to clear its internal hash table and seen records list between each run. This saves us from the constant re-allocations. This is worth an ~18.5% speed increase (3.75s -> 3.05s) in my tests. Differential Revision: https://reviews.llvm.org/D33506 llvm-svn: 303919
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView')
-rw-r--r--llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp13
-rw-r--r--llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp15
2 files changed, 19 insertions, 9 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp b/llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp
index 4894277947b..93c1198e36c 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp
@@ -78,6 +78,8 @@ private:
public:
TypeHasher(BumpPtrAllocator &RecordStorage) : RecordStorage(RecordStorage) {}
+ void reset() { HashedRecords.clear(); }
+
/// Takes the bytes of type record, inserts them into the hash table, saves
/// them, and returns a pointer to an identical stable type record along with
/// its type index in the destination stream.
@@ -172,6 +174,17 @@ ArrayRef<ArrayRef<uint8_t>> TypeSerializer::records() const {
return SeenRecords;
}
+void TypeSerializer::reset() {
+ if (Hasher)
+ Hasher->reset();
+ Writer.setOffset(0);
+ CurrentSegment = RecordSegment();
+ FieldListSegments.clear();
+ TypeKind.reset();
+ MemberKind.reset();
+ SeenRecords.clear();
+}
+
TypeIndex TypeSerializer::insertRecordBytes(ArrayRef<uint8_t> &Record) {
assert(!TypeKind.hasValue() && "Already in a type mapping!");
assert(Writer.getOffset() == 0 && "Stream has data already!");
diff --git a/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp b/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
index 0f8357ca80f..c7f256b838a 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
@@ -490,21 +490,18 @@ Error TypeStreamMerger::visitKnownRecord(CVType &CVR, FieldListRecord &R) {
assert(DestTypeStream);
// Visit the members inside the field list.
HadUntranslatedMember = false;
- FieldListBuilder = llvm::make_unique<FieldListRecordBuilder>(*DestTypeStream);
+ if (!FieldListBuilder)
+ FieldListBuilder =
+ llvm::make_unique<FieldListRecordBuilder>(*DestTypeStream);
FieldListBuilder->begin();
if (auto EC = codeview::visitMemberRecordStream(CVR.content(), *this))
return EC;
// Write the record if we translated all field list members.
- TypeIndex DestIdx = Untranslated;
- if (!HadUntranslatedMember)
- DestIdx = FieldListBuilder->end();
- else
- FieldListBuilder->reset();
- addMapping(DestIdx);
-
- FieldListBuilder.reset();
+ TypeIndex DestIdx = FieldListBuilder->end(!HadUntranslatedMember);
+ addMapping(HadUntranslatedMember ? Untranslated : DestIdx);
+
return Error::success();
}
OpenPOWER on IntegriCloud