[llvm] r319456 - Split TypeTableBuilder into two classes.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 30 10:39:50 PST 2017
Author: zturner
Date: Thu Nov 30 10:39:50 2017
New Revision: 319456
URL: http://llvm.org/viewvc/llvm-project?rev=319456&view=rev
Log:
Split TypeTableBuilder into two classes.
Added:
llvm/trunk/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
llvm/trunk/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
llvm/trunk/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp
llvm/trunk/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
Removed:
llvm/trunk/include/llvm/DebugInfo/CodeView/TypeTableBuilder.h
llvm/trunk/lib/DebugInfo/CodeView/TypeTableBuilder.cpp
Modified:
llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h
llvm/trunk/include/llvm/ObjectYAML/CodeViewYAMLTypes.h
llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt
llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
llvm/trunk/lib/ObjectYAML/CodeViewYAMLTypes.cpp
llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
llvm/trunk/tools/llvm-readobj/ObjDumper.h
llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
llvm/trunk/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp
llvm/trunk/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp
Added: llvm/trunk/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h?rev=319456&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h Thu Nov 30 10:39:50 2017
@@ -0,0 +1,70 @@
+//===- AppendingTypeTableBuilder.h -------------------------------*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_CODEVIEW_APPENDINGTYPETABLEBUILDER_H
+#define LLVM_DEBUGINFO_CODEVIEW_APPENDINGTYPETABLEBUILDER_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/SimpleTypeSerializer.h"
+#include "llvm/DebugInfo/CodeView/TypeCollection.h"
+#include "llvm/DebugInfo/CodeView/TypeIndex.h"
+#include "llvm/Support/Allocator.h"
+#include <cassert>
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+namespace llvm {
+namespace codeview {
+
+class ContinuationRecordBuilder;
+
+class AppendingTypeTableBuilder : public TypeCollection {
+
+ BumpPtrAllocator &RecordStorage;
+ SimpleTypeSerializer SimpleSerializer;
+
+ /// Contains a list of all records indexed by TypeIndex.toArrayIndex().
+ SmallVector<ArrayRef<uint8_t>, 2> SeenRecords;
+
+public:
+ explicit AppendingTypeTableBuilder(BumpPtrAllocator &Storage);
+ ~AppendingTypeTableBuilder();
+
+ // TypeTableCollection overrides
+ Optional<TypeIndex> getFirst() override;
+ Optional<TypeIndex> getNext(TypeIndex Prev) override;
+ CVType getType(TypeIndex Index) override;
+ StringRef getTypeName(TypeIndex Index) override;
+ bool contains(TypeIndex Index) override;
+ uint32_t size() override;
+ uint32_t capacity() override;
+
+ // public interface
+ void reset();
+ TypeIndex nextTypeIndex() const;
+
+ BumpPtrAllocator &getAllocator() { return RecordStorage; }
+
+ ArrayRef<ArrayRef<uint8_t>> records() const;
+ TypeIndex insertRecordBytes(ArrayRef<uint8_t> &Record);
+ TypeIndex insertRecord(ContinuationRecordBuilder &Builder);
+
+ template <typename T> TypeIndex writeLeafType(T &Record) {
+ ArrayRef<uint8_t> Data = SimpleSerializer.serialize(Record);
+ return insertRecordBytes(Data);
+ }
+};
+
+} // end namespace codeview
+} // end namespace llvm
+
+#endif // LLVM_DEBUGINFO_CODEVIEW_TYPETABLEBUILDER_H
Added: llvm/trunk/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h?rev=319456&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h Thu Nov 30 10:39:50 2017
@@ -0,0 +1,77 @@
+//===- MergingTypeTableBuilder.h ---------------------------------*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H
+#define LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/SimpleTypeSerializer.h"
+#include "llvm/DebugInfo/CodeView/TypeCollection.h"
+#include "llvm/DebugInfo/CodeView/TypeIndex.h"
+#include "llvm/DebugInfo/CodeView/TypeRecord.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/Error.h"
+#include <cassert>
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+namespace llvm {
+namespace codeview {
+
+class ContinuationRecordBuilder;
+class TypeHasher;
+
+class MergingTypeTableBuilder : public TypeCollection {
+
+ BumpPtrAllocator &RecordStorage;
+ SimpleTypeSerializer SimpleSerializer;
+
+ /// Private type record hashing implementation details are handled here.
+ std::unique_ptr<TypeHasher> Hasher;
+
+ /// Contains a list of all records indexed by TypeIndex.toArrayIndex().
+ SmallVector<ArrayRef<uint8_t>, 2> SeenRecords;
+
+public:
+ explicit MergingTypeTableBuilder(BumpPtrAllocator &Storage);
+ ~MergingTypeTableBuilder();
+
+ // TypeTableCollection overrides
+ Optional<TypeIndex> getFirst() override;
+ Optional<TypeIndex> getNext(TypeIndex Prev) override;
+ CVType getType(TypeIndex Index) override;
+ StringRef getTypeName(TypeIndex Index) override;
+ bool contains(TypeIndex Index) override;
+ uint32_t size() override;
+ uint32_t capacity() override;
+
+ // public interface
+ void reset();
+ TypeIndex nextTypeIndex() const;
+
+ BumpPtrAllocator &getAllocator() { return RecordStorage; }
+
+ ArrayRef<ArrayRef<uint8_t>> records() const;
+ TypeIndex insertRecordBytes(ArrayRef<uint8_t> &Record);
+ TypeIndex insertRecord(ContinuationRecordBuilder &Builder);
+
+ template <typename T> TypeIndex writeLeafType(T &Record) {
+ ArrayRef<uint8_t> Data = SimpleSerializer.serialize(Record);
+ return insertRecordBytes(Data);
+ }
+};
+
+} // end namespace codeview
+} // end namespace llvm
+
+#endif // LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h?rev=319456&r1=319455&r2=319456&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h Thu Nov 30 10:39:50 2017
@@ -19,7 +19,7 @@ namespace llvm {
namespace codeview {
class TypeIndex;
-class TypeTableBuilder;
+class MergingTypeTableBuilder;
/// \brief Merge one set of type records into another. This method assumes
/// that all records are type records, and there are no Id records present.
@@ -34,7 +34,7 @@ class TypeTableBuilder;
///
/// \returns Error::success() if the operation succeeded, otherwise an
/// appropriate error code.
-Error mergeTypeRecords(TypeTableBuilder &Dest,
+Error mergeTypeRecords(MergingTypeTableBuilder &Dest,
SmallVectorImpl<TypeIndex> &SourceToDest,
const CVTypeArray &Types);
@@ -59,7 +59,7 @@ Error mergeTypeRecords(TypeTableBuilder
///
/// \returns Error::success() if the operation succeeded, otherwise an
/// appropriate error code.
-Error mergeIdRecords(TypeTableBuilder &Dest, ArrayRef<TypeIndex> Types,
+Error mergeIdRecords(MergingTypeTableBuilder &Dest, ArrayRef<TypeIndex> Types,
SmallVectorImpl<TypeIndex> &SourceToDest,
const CVTypeArray &Ids);
@@ -78,8 +78,8 @@ Error mergeIdRecords(TypeTableBuilder &D
///
/// \returns Error::success() if the operation succeeded, otherwise an
/// appropriate error code.
-Error mergeTypeAndIdRecords(TypeTableBuilder &DestIds,
- TypeTableBuilder &DestTypes,
+Error mergeTypeAndIdRecords(MergingTypeTableBuilder &DestIds,
+ MergingTypeTableBuilder &DestTypes,
SmallVectorImpl<TypeIndex> &SourceToDest,
const CVTypeArray &IdsAndTypes);
Removed: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeTableBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeTableBuilder.h?rev=319455&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeTableBuilder.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeTableBuilder.h (removed)
@@ -1,77 +0,0 @@
-//===- TypeTableBuilder.h ----------------------------------------*- C++-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPETABLEBUILDER_H
-#define LLVM_DEBUGINFO_CODEVIEW_TYPETABLEBUILDER_H
-
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Optional.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/DebugInfo/CodeView/CodeView.h"
-#include "llvm/DebugInfo/CodeView/SimpleTypeSerializer.h"
-#include "llvm/DebugInfo/CodeView/TypeCollection.h"
-#include "llvm/DebugInfo/CodeView/TypeIndex.h"
-#include "llvm/DebugInfo/CodeView/TypeRecord.h"
-#include "llvm/Support/Allocator.h"
-#include "llvm/Support/Error.h"
-#include <cassert>
-#include <cstdint>
-#include <memory>
-#include <vector>
-
-namespace llvm {
-namespace codeview {
-
-class ContinuationRecordBuilder;
-class TypeHasher;
-
-class TypeTableBuilder : public TypeCollection {
-
- BumpPtrAllocator &RecordStorage;
- SimpleTypeSerializer SimpleSerializer;
-
- /// Private type record hashing implementation details are handled here.
- std::unique_ptr<TypeHasher> Hasher;
-
- /// Contains a list of all records indexed by TypeIndex.toArrayIndex().
- SmallVector<ArrayRef<uint8_t>, 2> SeenRecords;
-
-public:
- explicit TypeTableBuilder(BumpPtrAllocator &Storage, bool Hash = true);
- ~TypeTableBuilder();
-
- // TypeTableCollection overrides
- Optional<TypeIndex> getFirst() override;
- Optional<TypeIndex> getNext(TypeIndex Prev) override;
- CVType getType(TypeIndex Index) override;
- StringRef getTypeName(TypeIndex Index) override;
- bool contains(TypeIndex Index) override;
- uint32_t size() override;
- uint32_t capacity() override;
-
- // public interface
- void reset();
- TypeIndex nextTypeIndex() const;
-
- BumpPtrAllocator &getAllocator() { return RecordStorage; }
-
- ArrayRef<ArrayRef<uint8_t>> records() const;
- TypeIndex insertRecordBytes(ArrayRef<uint8_t> &Record);
- TypeIndex insertRecord(ContinuationRecordBuilder &Builder);
-
- template <typename T> TypeIndex writeLeafType(T &Record) {
- ArrayRef<uint8_t> Data = SimpleSerializer.serialize(Record);
- return insertRecordBytes(Data);
- }
-};
-
-} // end namespace codeview
-} // end namespace llvm
-
-#endif // LLVM_DEBUGINFO_CODEVIEW_TYPETABLEBUILDER_H
Modified: llvm/trunk/include/llvm/ObjectYAML/CodeViewYAMLTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ObjectYAML/CodeViewYAMLTypes.h?rev=319456&r1=319455&r2=319456&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ObjectYAML/CodeViewYAMLTypes.h (original)
+++ llvm/trunk/include/llvm/ObjectYAML/CodeViewYAMLTypes.h Thu Nov 30 10:39:50 2017
@@ -27,7 +27,7 @@
namespace llvm {
namespace codeview {
-class TypeTableBuilder;
+class AppendingTypeTableBuilder;
}
namespace CodeViewYAML {
@@ -47,7 +47,7 @@ struct LeafRecord {
std::shared_ptr<detail::LeafRecordBase> Leaf;
codeview::CVType
- toCodeViewRecord(codeview::TypeTableBuilder &Serializer) const;
+ toCodeViewRecord(codeview::AppendingTypeTableBuilder &Serializer) const;
static Expected<LeafRecord> fromCodeViewRecord(codeview::CVType Type);
};
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h?rev=319456&r1=319455&r2=319456&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h Thu Nov 30 10:39:50 2017
@@ -23,8 +23,8 @@
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
-#include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Compiler.h"
@@ -52,7 +52,7 @@ class MachineFunction;
class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase {
MCStreamer &OS;
BumpPtrAllocator Allocator;
- codeview::TypeTableBuilder TypeTable;
+ codeview::MergingTypeTableBuilder TypeTable;
/// Represents the most general definition range.
struct LocalVarDefRange {
Added: llvm/trunk/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp?rev=319456&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp (added)
+++ llvm/trunk/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp Thu Nov 30 10:39:50 2017
@@ -0,0 +1,101 @@
+//===- AppendingTypeTableBuilder.cpp --------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h"
+#include "llvm/DebugInfo/CodeView/RecordSerialization.h"
+#include "llvm/DebugInfo/CodeView/TypeIndex.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/BinaryByteStream.h"
+#include "llvm/Support/BinaryStreamWriter.h"
+#include "llvm/Support/Endian.h"
+#include "llvm/Support/Error.h"
+#include <algorithm>
+#include <cassert>
+#include <cstdint>
+#include <cstring>
+
+using namespace llvm;
+using namespace llvm::codeview;
+
+TypeIndex AppendingTypeTableBuilder::nextTypeIndex() const {
+ return TypeIndex::fromArrayIndex(SeenRecords.size());
+}
+
+AppendingTypeTableBuilder::AppendingTypeTableBuilder(BumpPtrAllocator &Storage)
+ : RecordStorage(Storage) {}
+
+AppendingTypeTableBuilder::~AppendingTypeTableBuilder() = default;
+
+Optional<TypeIndex> AppendingTypeTableBuilder::getFirst() {
+ if (empty())
+ return None;
+
+ return TypeIndex(TypeIndex::FirstNonSimpleIndex);
+}
+
+Optional<TypeIndex> AppendingTypeTableBuilder::getNext(TypeIndex Prev) {
+ if (++Prev == nextTypeIndex())
+ return None;
+ return Prev;
+}
+
+CVType AppendingTypeTableBuilder::getType(TypeIndex Index) {
+ CVType Type;
+ Type.RecordData = SeenRecords[Index.toArrayIndex()];
+ const RecordPrefix *P =
+ reinterpret_cast<const RecordPrefix *>(Type.RecordData.data());
+ Type.Type = static_cast<TypeLeafKind>(uint16_t(P->RecordKind));
+ return Type;
+}
+
+StringRef AppendingTypeTableBuilder::getTypeName(TypeIndex Index) {
+ llvm_unreachable("Method not implemented");
+}
+
+bool AppendingTypeTableBuilder::contains(TypeIndex Index) {
+ if (Index.isSimple() || Index.isNoneType())
+ return false;
+
+ return Index.toArrayIndex() < SeenRecords.size();
+}
+
+uint32_t AppendingTypeTableBuilder::size() { return SeenRecords.size(); }
+
+uint32_t AppendingTypeTableBuilder::capacity() { return SeenRecords.size(); }
+
+ArrayRef<ArrayRef<uint8_t>> AppendingTypeTableBuilder::records() const {
+ return SeenRecords;
+}
+
+void AppendingTypeTableBuilder::reset() { SeenRecords.clear(); }
+
+TypeIndex
+AppendingTypeTableBuilder::insertRecordBytes(ArrayRef<uint8_t> &Record) {
+ TypeIndex NewTI = nextTypeIndex();
+ uint8_t *Stable = RecordStorage.Allocate<uint8_t>(Record.size());
+ memcpy(Stable, Record.data(), Record.size());
+ Record = ArrayRef<uint8_t>(Stable, Record.size());
+ SeenRecords.push_back(Record);
+ return NewTI;
+}
+
+TypeIndex
+AppendingTypeTableBuilder::insertRecord(ContinuationRecordBuilder &Builder) {
+ TypeIndex TI;
+ auto Fragments = Builder.end(nextTypeIndex());
+ assert(!Fragments.empty());
+ for (auto C : Fragments)
+ TI = insertRecordBytes(C.RecordData);
+ return TI;
+}
Modified: llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt?rev=319456&r1=319455&r2=319456&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt Thu Nov 30 10:39:50 2017
@@ -1,4 +1,5 @@
add_llvm_library(LLVMDebugInfoCodeView
+ AppendingTypeTableBuilder.cpp
CodeViewError.cpp
CodeViewRecordIO.cpp
ContinuationRecordBuilder.cpp
@@ -20,6 +21,7 @@ add_llvm_library(LLVMDebugInfoCodeView
Formatters.cpp
LazyRandomTypeCollection.cpp
Line.cpp
+ MergingTypeTableBuilder.cpp
RecordName.cpp
RecordSerialization.cpp
SimpleTypeSerializer.cpp
@@ -31,7 +33,6 @@ add_llvm_library(LLVMDebugInfoCodeView
TypeIndex.cpp
TypeIndexDiscovery.cpp
TypeRecordMapping.cpp
- TypeTableBuilder.cpp
TypeStreamMerger.cpp
TypeTableCollection.cpp
Added: llvm/trunk/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp?rev=319456&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp (added)
+++ llvm/trunk/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp Thu Nov 30 10:39:50 2017
@@ -0,0 +1,206 @@
+//===- MergingTypeTableBuilder.cpp ----------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h"
+#include "llvm/DebugInfo/CodeView/RecordSerialization.h"
+#include "llvm/DebugInfo/CodeView/TypeIndex.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/BinaryByteStream.h"
+#include "llvm/Support/BinaryStreamWriter.h"
+#include "llvm/Support/Endian.h"
+#include "llvm/Support/Error.h"
+#include <algorithm>
+#include <cassert>
+#include <cstdint>
+#include <cstring>
+
+using namespace llvm;
+using namespace llvm::codeview;
+
+namespace {
+
+struct HashedType {
+ hash_code Hash;
+ ArrayRef<uint8_t> Data;
+ TypeIndex Index;
+};
+
+/// Wrapper around a poitner to a HashedType. Hash and equality operations are
+/// based on data in the pointee.
+struct HashedTypePtr {
+ HashedTypePtr() = default;
+ HashedTypePtr(HashedType *Ptr) : Ptr(Ptr) {}
+
+ HashedType *Ptr = nullptr;
+};
+
+} // end anonymous namespace
+
+namespace llvm {
+
+template <> struct DenseMapInfo<HashedTypePtr> {
+ static inline HashedTypePtr getEmptyKey() { return HashedTypePtr(nullptr); }
+
+ static inline HashedTypePtr getTombstoneKey() {
+ return HashedTypePtr(reinterpret_cast<HashedType *>(1));
+ }
+
+ static unsigned getHashValue(HashedTypePtr Val) {
+ assert(Val.Ptr != getEmptyKey().Ptr && Val.Ptr != getTombstoneKey().Ptr);
+ return Val.Ptr->Hash;
+ }
+
+ static bool isEqual(HashedTypePtr LHSP, HashedTypePtr RHSP) {
+ HashedType *LHS = LHSP.Ptr;
+ HashedType *RHS = RHSP.Ptr;
+ if (RHS == getEmptyKey().Ptr || RHS == getTombstoneKey().Ptr)
+ return LHS == RHS;
+ if (LHS->Hash != RHS->Hash)
+ return false;
+ return LHS->Data == RHS->Data;
+ }
+};
+
+} // end namespace llvm
+
+/// Private implementation so that we don't leak our DenseMap instantiations to
+/// users.
+class llvm::codeview::TypeHasher {
+private:
+ /// Storage for type record provided by the caller. Records will outlive the
+ /// hasher object, so they should be allocated here.
+ BumpPtrAllocator &RecordStorage;
+
+ /// Storage for hash keys. These only need to live as long as the hashing
+ /// operation.
+ BumpPtrAllocator KeyStorage;
+
+ /// Hash table. We really want a DenseMap<ArrayRef<uint8_t>, TypeIndex> here,
+ /// but DenseMap is inefficient when the keys are long (like type records)
+ /// because it recomputes the hash value of every key when it grows. This
+ /// value type stores the hash out of line in KeyStorage, so that table
+ /// entries are small and easy to rehash.
+ DenseSet<HashedTypePtr> HashedRecords;
+
+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.
+ TypeIndex getOrCreateRecord(ArrayRef<uint8_t> &Record, TypeIndex TI);
+};
+
+TypeIndex TypeHasher::getOrCreateRecord(ArrayRef<uint8_t> &Record,
+ TypeIndex TI) {
+ assert(Record.size() < UINT32_MAX && "Record too big");
+ assert(Record.size() % 4 == 0 && "Record is not aligned to 4 bytes!");
+
+ // Compute the hash up front so we can store it in the key.
+ HashedType TempHashedType = {hash_value(Record), Record, TI};
+ auto Result = HashedRecords.insert(HashedTypePtr(&TempHashedType));
+ HashedType *&Hashed = Result.first->Ptr;
+
+ if (Result.second) {
+ // This was a new type record. We need stable storage for both the key and
+ // the record. The record should outlive the hashing operation.
+ Hashed = KeyStorage.Allocate<HashedType>();
+ *Hashed = TempHashedType;
+
+ uint8_t *Stable = RecordStorage.Allocate<uint8_t>(Record.size());
+ memcpy(Stable, Record.data(), Record.size());
+ Hashed->Data = makeArrayRef(Stable, Record.size());
+ }
+
+ // Update the caller's copy of Record to point a stable copy.
+ Record = Hashed->Data;
+ return Hashed->Index;
+}
+
+TypeIndex MergingTypeTableBuilder::nextTypeIndex() const {
+ return TypeIndex::fromArrayIndex(SeenRecords.size());
+}
+
+MergingTypeTableBuilder::MergingTypeTableBuilder(BumpPtrAllocator &Storage)
+ : RecordStorage(Storage) {
+ Hasher = llvm::make_unique<TypeHasher>(Storage);
+}
+
+MergingTypeTableBuilder::~MergingTypeTableBuilder() = default;
+
+Optional<TypeIndex> MergingTypeTableBuilder::getFirst() {
+ if (empty())
+ return None;
+
+ return TypeIndex(TypeIndex::FirstNonSimpleIndex);
+}
+
+Optional<TypeIndex> MergingTypeTableBuilder::getNext(TypeIndex Prev) {
+ if (++Prev == nextTypeIndex())
+ return None;
+ return Prev;
+}
+
+CVType MergingTypeTableBuilder::getType(TypeIndex Index) {
+ CVType Type;
+ Type.RecordData = SeenRecords[Index.toArrayIndex()];
+ const RecordPrefix *P =
+ reinterpret_cast<const RecordPrefix *>(Type.RecordData.data());
+ Type.Type = static_cast<TypeLeafKind>(uint16_t(P->RecordKind));
+ return Type;
+}
+
+StringRef MergingTypeTableBuilder::getTypeName(TypeIndex Index) {
+ llvm_unreachable("Method not implemented");
+}
+
+bool MergingTypeTableBuilder::contains(TypeIndex Index) {
+ if (Index.isSimple() || Index.isNoneType())
+ return false;
+
+ return Index.toArrayIndex() < SeenRecords.size();
+}
+
+uint32_t MergingTypeTableBuilder::size() { return SeenRecords.size(); }
+
+uint32_t MergingTypeTableBuilder::capacity() { return SeenRecords.size(); }
+
+ArrayRef<ArrayRef<uint8_t>> MergingTypeTableBuilder::records() const {
+ return SeenRecords;
+}
+
+void MergingTypeTableBuilder::reset() {
+ Hasher->reset();
+ SeenRecords.clear();
+}
+
+TypeIndex
+MergingTypeTableBuilder::insertRecordBytes(ArrayRef<uint8_t> &Record) {
+ TypeIndex ActualTI = Hasher->getOrCreateRecord(Record, nextTypeIndex());
+ if (nextTypeIndex() == ActualTI)
+ SeenRecords.push_back(Record);
+ return ActualTI;
+}
+
+TypeIndex
+MergingTypeTableBuilder::insertRecord(ContinuationRecordBuilder &Builder) {
+ TypeIndex TI;
+ auto Fragments = Builder.end(nextTypeIndex());
+ assert(!Fragments.empty());
+ for (auto C : Fragments)
+ TI = insertRecordBytes(C.RecordData);
+ return TI;
+}
Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp?rev=319456&r1=319455&r2=319456&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp Thu Nov 30 10:39:50 2017
@@ -10,11 +10,11 @@
#include "llvm/DebugInfo/CodeView/TypeStreamMerger.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h"
#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/CodeView/TypeIndexDiscovery.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
-#include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ScopedPrinter.h"
@@ -64,12 +64,14 @@ public:
static const TypeIndex Untranslated;
- Error mergeTypesAndIds(TypeTableBuilder &DestIds, TypeTableBuilder &DestTypes,
+ Error mergeTypesAndIds(MergingTypeTableBuilder &DestIds,
+ MergingTypeTableBuilder &DestTypes,
const CVTypeArray &IdsAndTypes);
- Error mergeIdRecords(TypeTableBuilder &Dest,
+ Error mergeIdRecords(MergingTypeTableBuilder &Dest,
ArrayRef<TypeIndex> TypeSourceToDest,
const CVTypeArray &Ids);
- Error mergeTypeRecords(TypeTableBuilder &Dest, const CVTypeArray &Types);
+ Error mergeTypeRecords(MergingTypeTableBuilder &Dest,
+ const CVTypeArray &Types);
private:
Error doit(const CVTypeArray &Types);
@@ -106,8 +108,8 @@ private:
TypeIndex CurIndex{TypeIndex::FirstNonSimpleIndex};
- TypeTableBuilder *DestIdStream = nullptr;
- TypeTableBuilder *DestTypeStream = nullptr;
+ MergingTypeTableBuilder *DestIdStream = nullptr;
+ MergingTypeTableBuilder *DestTypeStream = nullptr;
// If we're only mapping id records, this array contains the mapping for
// type records.
@@ -221,14 +223,14 @@ bool TypeStreamMerger::remapItemIndex(Ty
return remapIndex(Idx, IndexMap);
}
-Error TypeStreamMerger::mergeTypeRecords(TypeTableBuilder &Dest,
+Error TypeStreamMerger::mergeTypeRecords(MergingTypeTableBuilder &Dest,
const CVTypeArray &Types) {
DestTypeStream = &Dest;
return doit(Types);
}
-Error TypeStreamMerger::mergeIdRecords(TypeTableBuilder &Dest,
+Error TypeStreamMerger::mergeIdRecords(MergingTypeTableBuilder &Dest,
ArrayRef<TypeIndex> TypeSourceToDest,
const CVTypeArray &Ids) {
DestIdStream = &Dest;
@@ -237,8 +239,8 @@ Error TypeStreamMerger::mergeIdRecords(T
return doit(Ids);
}
-Error TypeStreamMerger::mergeTypesAndIds(TypeTableBuilder &DestIds,
- TypeTableBuilder &DestTypes,
+Error TypeStreamMerger::mergeTypesAndIds(MergingTypeTableBuilder &DestIds,
+ MergingTypeTableBuilder &DestTypes,
const CVTypeArray &IdsAndTypes) {
DestIdStream = &DestIds;
DestTypeStream = &DestTypes;
@@ -286,7 +288,7 @@ Error TypeStreamMerger::remapAllTypes(co
}
Error TypeStreamMerger::remapType(const CVType &Type) {
- TypeTableBuilder &Dest =
+ MergingTypeTableBuilder &Dest =
isIdRecord(Type.kind()) ? *DestIdStream : *DestTypeStream;
RemappedType R(Type);
@@ -329,14 +331,14 @@ bool TypeStreamMerger::remapIndices(Rema
return Success;
}
-Error llvm::codeview::mergeTypeRecords(TypeTableBuilder &Dest,
+Error llvm::codeview::mergeTypeRecords(MergingTypeTableBuilder &Dest,
SmallVectorImpl<TypeIndex> &SourceToDest,
const CVTypeArray &Types) {
TypeStreamMerger M(SourceToDest);
return M.mergeTypeRecords(Dest, Types);
}
-Error llvm::codeview::mergeIdRecords(TypeTableBuilder &Dest,
+Error llvm::codeview::mergeIdRecords(MergingTypeTableBuilder &Dest,
ArrayRef<TypeIndex> TypeSourceToDest,
SmallVectorImpl<TypeIndex> &SourceToDest,
const CVTypeArray &Ids) {
@@ -345,7 +347,7 @@ Error llvm::codeview::mergeIdRecords(Typ
}
Error llvm::codeview::mergeTypeAndIdRecords(
- TypeTableBuilder &DestIds, TypeTableBuilder &DestTypes,
+ MergingTypeTableBuilder &DestIds, MergingTypeTableBuilder &DestTypes,
SmallVectorImpl<TypeIndex> &SourceToDest, const CVTypeArray &IdsAndTypes) {
TypeStreamMerger M(SourceToDest);
return M.mergeTypesAndIds(DestIds, DestTypes, IdsAndTypes);
Removed: llvm/trunk/lib/DebugInfo/CodeView/TypeTableBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeTableBuilder.cpp?rev=319455&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/TypeTableBuilder.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/TypeTableBuilder.cpp (removed)
@@ -1,215 +0,0 @@
-//===- TypeSerialzier.cpp -------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/DebugInfo/CodeView/CodeView.h"
-#include "llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h"
-#include "llvm/DebugInfo/CodeView/RecordSerialization.h"
-#include "llvm/DebugInfo/CodeView/TypeIndex.h"
-#include "llvm/Support/Allocator.h"
-#include "llvm/Support/BinaryByteStream.h"
-#include "llvm/Support/BinaryStreamWriter.h"
-#include "llvm/Support/Endian.h"
-#include "llvm/Support/Error.h"
-#include <algorithm>
-#include <cassert>
-#include <cstdint>
-#include <cstring>
-
-using namespace llvm;
-using namespace llvm::codeview;
-
-namespace {
-
-struct HashedType {
- hash_code Hash;
- ArrayRef<uint8_t> Data;
- TypeIndex Index;
-};
-
-/// Wrapper around a poitner to a HashedType. Hash and equality operations are
-/// based on data in the pointee.
-struct HashedTypePtr {
- HashedTypePtr() = default;
- HashedTypePtr(HashedType *Ptr) : Ptr(Ptr) {}
-
- HashedType *Ptr = nullptr;
-};
-
-} // end anonymous namespace
-
-namespace llvm {
-
-template <> struct DenseMapInfo<HashedTypePtr> {
- static inline HashedTypePtr getEmptyKey() { return HashedTypePtr(nullptr); }
-
- static inline HashedTypePtr getTombstoneKey() {
- return HashedTypePtr(reinterpret_cast<HashedType *>(1));
- }
-
- static unsigned getHashValue(HashedTypePtr Val) {
- assert(Val.Ptr != getEmptyKey().Ptr && Val.Ptr != getTombstoneKey().Ptr);
- return Val.Ptr->Hash;
- }
-
- static bool isEqual(HashedTypePtr LHSP, HashedTypePtr RHSP) {
- HashedType *LHS = LHSP.Ptr;
- HashedType *RHS = RHSP.Ptr;
- if (RHS == getEmptyKey().Ptr || RHS == getTombstoneKey().Ptr)
- return LHS == RHS;
- if (LHS->Hash != RHS->Hash)
- return false;
- return LHS->Data == RHS->Data;
- }
-};
-
-} // end namespace llvm
-
-/// Private implementation so that we don't leak our DenseMap instantiations to
-/// users.
-class llvm::codeview::TypeHasher {
-private:
- /// Storage for type record provided by the caller. Records will outlive the
- /// hasher object, so they should be allocated here.
- BumpPtrAllocator &RecordStorage;
-
- /// Storage for hash keys. These only need to live as long as the hashing
- /// operation.
- BumpPtrAllocator KeyStorage;
-
- /// Hash table. We really want a DenseMap<ArrayRef<uint8_t>, TypeIndex> here,
- /// but DenseMap is inefficient when the keys are long (like type records)
- /// because it recomputes the hash value of every key when it grows. This
- /// value type stores the hash out of line in KeyStorage, so that table
- /// entries are small and easy to rehash.
- DenseSet<HashedTypePtr> HashedRecords;
-
-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.
- TypeIndex getOrCreateRecord(ArrayRef<uint8_t> &Record, TypeIndex TI);
-};
-
-TypeIndex TypeHasher::getOrCreateRecord(ArrayRef<uint8_t> &Record,
- TypeIndex TI) {
- assert(Record.size() < UINT32_MAX && "Record too big");
- assert(Record.size() % 4 == 0 && "Record is not aligned to 4 bytes!");
-
- // Compute the hash up front so we can store it in the key.
- HashedType TempHashedType = {hash_value(Record), Record, TI};
- auto Result = HashedRecords.insert(HashedTypePtr(&TempHashedType));
- HashedType *&Hashed = Result.first->Ptr;
-
- if (Result.second) {
- // This was a new type record. We need stable storage for both the key and
- // the record. The record should outlive the hashing operation.
- Hashed = KeyStorage.Allocate<HashedType>();
- *Hashed = TempHashedType;
-
- uint8_t *Stable = RecordStorage.Allocate<uint8_t>(Record.size());
- memcpy(Stable, Record.data(), Record.size());
- Hashed->Data = makeArrayRef(Stable, Record.size());
- }
-
- // Update the caller's copy of Record to point a stable copy.
- Record = Hashed->Data;
- return Hashed->Index;
-}
-
-TypeIndex TypeTableBuilder::nextTypeIndex() const {
- return TypeIndex::fromArrayIndex(SeenRecords.size());
-}
-
-TypeTableBuilder::TypeTableBuilder(BumpPtrAllocator &Storage, bool Hash)
- : RecordStorage(Storage) {
- if (Hash)
- Hasher = llvm::make_unique<TypeHasher>(Storage);
-}
-
-TypeTableBuilder::~TypeTableBuilder() = default;
-
-Optional<TypeIndex> TypeTableBuilder::getFirst() {
- if (empty())
- return None;
-
- return TypeIndex(TypeIndex::FirstNonSimpleIndex);
-}
-
-Optional<TypeIndex> TypeTableBuilder::getNext(TypeIndex Prev) {
- if (++Prev == nextTypeIndex())
- return None;
- return Prev;
-}
-
-CVType TypeTableBuilder::getType(TypeIndex Index) {
- CVType Type;
- Type.RecordData = SeenRecords[Index.toArrayIndex()];
- const RecordPrefix *P =
- reinterpret_cast<const RecordPrefix *>(Type.RecordData.data());
- Type.Type = static_cast<TypeLeafKind>(uint16_t(P->RecordKind));
- return Type;
-}
-
-StringRef TypeTableBuilder::getTypeName(TypeIndex Index) {
- llvm_unreachable("Method not implemented");
-}
-
-bool TypeTableBuilder::contains(TypeIndex Index) {
- if (Index.isSimple() || Index.isNoneType())
- return false;
-
- return Index.toArrayIndex() < SeenRecords.size();
-}
-
-uint32_t TypeTableBuilder::size() { return SeenRecords.size(); }
-
-uint32_t TypeTableBuilder::capacity() { return SeenRecords.size(); }
-
-ArrayRef<ArrayRef<uint8_t>> TypeTableBuilder::records() const {
- return SeenRecords;
-}
-
-void TypeTableBuilder::reset() {
- if (Hasher)
- Hasher->reset();
- SeenRecords.clear();
-}
-
-TypeIndex TypeTableBuilder::insertRecordBytes(ArrayRef<uint8_t> &Record) {
- if (Hasher) {
- TypeIndex ActualTI = Hasher->getOrCreateRecord(Record, nextTypeIndex());
- if (nextTypeIndex() == ActualTI)
- SeenRecords.push_back(Record);
- return ActualTI;
- }
-
- TypeIndex NewTI = nextTypeIndex();
- uint8_t *Stable = RecordStorage.Allocate<uint8_t>(Record.size());
- memcpy(Stable, Record.data(), Record.size());
- Record = ArrayRef<uint8_t>(Stable, Record.size());
- SeenRecords.push_back(Record);
- return NewTI;
-}
-
-TypeIndex TypeTableBuilder::insertRecord(ContinuationRecordBuilder &Builder) {
- TypeIndex TI;
- auto Fragments = Builder.end(nextTypeIndex());
- assert(!Fragments.empty());
- for (auto C : Fragments)
- TI = insertRecordBytes(C.RecordData);
- return TI;
-}
Modified: llvm/trunk/lib/ObjectYAML/CodeViewYAMLTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/CodeViewYAMLTypes.cpp?rev=319456&r1=319455&r2=319456&view=diff
==============================================================================
--- llvm/trunk/lib/ObjectYAML/CodeViewYAMLTypes.cpp (original)
+++ llvm/trunk/lib/ObjectYAML/CodeViewYAMLTypes.cpp Thu Nov 30 10:39:50 2017
@@ -17,13 +17,13 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/COFF.h"
+#include "llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h"
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
#include "llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h"
#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
-#include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/BinaryStreamReader.h"
@@ -83,7 +83,7 @@ struct LeafRecordBase {
virtual ~LeafRecordBase() = default;
virtual void map(yaml::IO &io) = 0;
- virtual CVType toCodeViewRecord(TypeTableBuilder &TS) const = 0;
+ virtual CVType toCodeViewRecord(AppendingTypeTableBuilder &TS) const = 0;
virtual Error fromCodeViewRecord(CVType Type) = 0;
};
@@ -97,7 +97,7 @@ template <typename T> struct LeafRecordI
return TypeDeserializer::deserializeAs<T>(Type, Record);
}
- CVType toCodeViewRecord(TypeTableBuilder &TS) const override {
+ CVType toCodeViewRecord(AppendingTypeTableBuilder &TS) const override {
TS.writeLeafType(Record);
return CVType(Kind, TS.records().back());
}
@@ -109,7 +109,7 @@ template <> struct LeafRecordImpl<FieldL
explicit LeafRecordImpl(TypeLeafKind K) : LeafRecordBase(K) {}
void map(yaml::IO &io) override;
- CVType toCodeViewRecord(TypeTableBuilder &TS) const override;
+ CVType toCodeViewRecord(AppendingTypeTableBuilder &TS) const override;
Error fromCodeViewRecord(CVType Type) override;
std::vector<MemberRecord> Members;
@@ -489,8 +489,8 @@ Error LeafRecordImpl<FieldListRecord>::f
return visitMemberRecordStream(Type.content(), V);
}
-CVType
-LeafRecordImpl<FieldListRecord>::toCodeViewRecord(TypeTableBuilder &TS) const {
+CVType LeafRecordImpl<FieldListRecord>::toCodeViewRecord(
+ AppendingTypeTableBuilder &TS) const {
ContinuationRecordBuilder CRB;
CRB.begin(ContinuationRecordKind::FieldList);
for (const auto &Member : Members) {
@@ -682,7 +682,8 @@ Expected<LeafRecord> LeafRecord::fromCod
return make_error<CodeViewError>(cv_error_code::corrupt_record);
}
-CVType LeafRecord::toCodeViewRecord(TypeTableBuilder &Serializer) const {
+CVType
+LeafRecord::toCodeViewRecord(AppendingTypeTableBuilder &Serializer) const {
return Leaf->toCodeViewRecord(Serializer);
}
@@ -782,7 +783,7 @@ llvm::CodeViewYAML::fromDebugT(ArrayRef<
ArrayRef<uint8_t> llvm::CodeViewYAML::toDebugT(ArrayRef<LeafRecord> Leafs,
BumpPtrAllocator &Alloc) {
- TypeTableBuilder TS(Alloc, false);
+ AppendingTypeTableBuilder TS(Alloc);
uint32_t Size = sizeof(uint32_t);
for (const auto &Leaf : Leafs) {
CVType T = Leaf.Leaf->toCodeViewRecord(TS);
Modified: llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp?rev=319456&r1=319455&r2=319456&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp Thu Nov 30 10:39:50 2017
@@ -35,13 +35,14 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/BinaryFormat/Magic.h"
#include "llvm/Config/config.h"
+#include "llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h"
#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
+#include "llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h"
#include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"
#include "llvm/DebugInfo/CodeView/TypeStreamMerger.h"
-#include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
#include "llvm/DebugInfo/MSF/MSFBuilder.h"
#include "llvm/DebugInfo/PDB/GenericError.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
@@ -727,7 +728,7 @@ static void yamlToPdb(StringRef Path) {
auto &TpiBuilder = Builder.getTpiBuilder();
const auto &Tpi = YamlObj.TpiStream.getValueOr(DefaultTpiStream);
TpiBuilder.setVersionHeader(Tpi.Version);
- TypeTableBuilder TS(Allocator);
+ AppendingTypeTableBuilder TS(Allocator);
for (const auto &R : Tpi.Records) {
CVType Type = R.toCodeViewRecord(TS);
TpiBuilder.addTypeRecord(Type.RecordData, None);
@@ -989,8 +990,8 @@ static void dumpPretty(StringRef Path) {
static void mergePdbs() {
BumpPtrAllocator Allocator;
- TypeTableBuilder MergedTpi(Allocator);
- TypeTableBuilder MergedIpi(Allocator);
+ MergingTypeTableBuilder MergedTpi(Allocator);
+ MergingTypeTableBuilder MergedIpi(Allocator);
// Create a Tpi and Ipi type table with all types from all input files.
for (const auto &Path : opts::merge::InputFilenames) {
Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=319456&r1=319455&r2=319456&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Thu Nov 30 10:39:50 2017
@@ -31,6 +31,7 @@
#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
#include "llvm/DebugInfo/CodeView/Line.h"
+#include "llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h"
#include "llvm/DebugInfo/CodeView/RecordSerialization.h"
#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
#include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h"
@@ -40,7 +41,6 @@
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/CodeView/TypeStreamMerger.h"
-#include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
#include "llvm/DebugInfo/CodeView/TypeTableCollection.h"
#include "llvm/Object/COFF.h"
#include "llvm/Object/ObjectFile.h"
@@ -96,8 +96,9 @@ public:
void printCOFFResources() override;
void printCOFFLoadConfig() override;
void printCodeViewDebugInfo() override;
- void mergeCodeViewTypes(llvm::codeview::TypeTableBuilder &CVIDs,
- llvm::codeview::TypeTableBuilder &CVTypes) override;
+ void
+ mergeCodeViewTypes(llvm::codeview::MergingTypeTableBuilder &CVIDs,
+ llvm::codeview::MergingTypeTableBuilder &CVTypes) override;
void printStackMap() const override;
private:
void printSymbol(const SymbolRef &Sym);
@@ -1194,8 +1195,8 @@ void COFFDumper::printFileNameForOffset(
W.printHex(Label, getFileNameForFileOffset(FileOffset), FileOffset);
}
-void COFFDumper::mergeCodeViewTypes(TypeTableBuilder &CVIDs,
- TypeTableBuilder &CVTypes) {
+void COFFDumper::mergeCodeViewTypes(MergingTypeTableBuilder &CVIDs,
+ MergingTypeTableBuilder &CVTypes) {
for (const SectionRef &S : Obj->sections()) {
StringRef SectionName;
error(S.getName(SectionName));
@@ -1803,9 +1804,9 @@ void COFFDumper::printStackMap() const {
StackMapV2Parser<support::big>(StackMapContentsArray));
}
-void llvm::dumpCodeViewMergedTypes(ScopedPrinter &Writer,
- llvm::codeview::TypeTableBuilder &IDTable,
- llvm::codeview::TypeTableBuilder &CVTypes) {
+void llvm::dumpCodeViewMergedTypes(
+ ScopedPrinter &Writer, llvm::codeview::MergingTypeTableBuilder &IDTable,
+ llvm::codeview::MergingTypeTableBuilder &CVTypes) {
// Flatten it first, then run our dumper on it.
SmallString<0> TypeBuf;
CVTypes.ForEachRecord([&](TypeIndex TI, const CVType &Record) {
Modified: llvm/trunk/tools/llvm-readobj/ObjDumper.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ObjDumper.h?rev=319456&r1=319455&r2=319456&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ObjDumper.h (original)
+++ llvm/trunk/tools/llvm-readobj/ObjDumper.h Thu Nov 30 10:39:50 2017
@@ -19,7 +19,7 @@ class COFFImportFile;
class ObjectFile;
}
namespace codeview {
-class TypeTableBuilder;
+class MergingTypeTableBuilder;
}
class ScopedPrinter;
@@ -67,8 +67,9 @@ public:
virtual void printCOFFResources() {}
virtual void printCOFFLoadConfig() { }
virtual void printCodeViewDebugInfo() { }
- virtual void mergeCodeViewTypes(llvm::codeview::TypeTableBuilder &CVIDs,
- llvm::codeview::TypeTableBuilder &CVTypes) {}
+ virtual void
+ mergeCodeViewTypes(llvm::codeview::MergingTypeTableBuilder &CVIDs,
+ llvm::codeview::MergingTypeTableBuilder &CVTypes) {}
// Only implemented for MachO.
virtual void printMachODataInCode() { }
@@ -102,9 +103,9 @@ std::error_code createWasmDumper(const o
void dumpCOFFImportFile(const object::COFFImportFile *File);
-void dumpCodeViewMergedTypes(ScopedPrinter &Writer,
- llvm::codeview::TypeTableBuilder &IDTable,
- llvm::codeview::TypeTableBuilder &TypeTable);
+void dumpCodeViewMergedTypes(
+ ScopedPrinter &Writer, llvm::codeview::MergingTypeTableBuilder &IDTable,
+ llvm::codeview::MergingTypeTableBuilder &TypeTable);
} // namespace llvm
Modified: llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp?rev=319456&r1=319455&r2=319456&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp Thu Nov 30 10:39:50 2017
@@ -23,7 +23,7 @@
#include "Error.h"
#include "ObjDumper.h"
#include "WindowsResourceDumper.h"
-#include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
+#include "llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/COFFImportFile.h"
#include "llvm/Object/ELFObjectFile.h"
@@ -353,8 +353,8 @@ struct ReadObjTypeTableBuilder {
: Allocator(), IDTable(Allocator), TypeTable(Allocator) {}
llvm::BumpPtrAllocator Allocator;
- llvm::codeview::TypeTableBuilder IDTable;
- llvm::codeview::TypeTableBuilder TypeTable;
+ llvm::codeview::MergingTypeTableBuilder IDTable;
+ llvm::codeview::MergingTypeTableBuilder TypeTable;
};
}
static ReadObjTypeTableBuilder CVTypes;
Modified: llvm/trunk/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp?rev=319456&r1=319455&r2=319456&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp (original)
+++ llvm/trunk/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp Thu Nov 30 10:39:50 2017
@@ -8,11 +8,11 @@
//===----------------------------------------------------------------------===//
#include "llvm/ADT/SmallBitVector.h"
+#include "llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h"
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/CodeView/TypeRecordMapping.h"
-#include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
#include "llvm/Support/Allocator.h"
@@ -94,7 +94,7 @@ public:
static void SetUpTestCase() {
GlobalState = llvm::make_unique<GlobalTestState>();
- TypeTableBuilder Builder(GlobalState->Allocator);
+ AppendingTypeTableBuilder Builder(GlobalState->Allocator);
uint32_t Offset = 0;
for (int I = 0; I < 11; ++I) {
@@ -351,7 +351,7 @@ TEST_F(RandomAccessVisitorTest, InnerChu
}
TEST_F(RandomAccessVisitorTest, CrossChunkName) {
- TypeTableBuilder Builder(GlobalState->Allocator);
+ AppendingTypeTableBuilder Builder(GlobalState->Allocator);
// TypeIndex 0
ClassRecord Class(TypeRecordKind::Class);
Modified: llvm/trunk/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp?rev=319456&r1=319455&r2=319456&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp (original)
+++ llvm/trunk/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp Thu Nov 30 10:39:50 2017
@@ -9,9 +9,9 @@
#include "llvm/DebugInfo/CodeView/TypeIndexDiscovery.h"
+#include "llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h"
#include "llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h"
#include "llvm/DebugInfo/CodeView/SymbolSerializer.h"
-#include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
#include "llvm/Support/Allocator.h"
#include "gmock/gmock.h"
@@ -26,7 +26,7 @@ public:
void SetUp() override {
Refs.clear();
- TTB = make_unique<TypeTableBuilder>(Storage);
+ TTB = make_unique<AppendingTypeTableBuilder>(Storage);
CRB = make_unique<ContinuationRecordBuilder>();
Symbols.clear();
}
@@ -76,8 +76,7 @@ protected:
discoverTypeIndicesInSymbols();
}
-
- std::unique_ptr<TypeTableBuilder> TTB;
+ std::unique_ptr<AppendingTypeTableBuilder> TTB;
private:
uint32_t countRefs(uint32_t RecordIndex) const {
More information about the llvm-commits
mailing list