mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-19 16:35:10 +00:00
Split TypeTableBuilder into two classes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319456 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
69d3274f50
commit
47856b25a7
70
include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
Normal file
70
include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
Normal file
@ -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
|
@ -1,4 +1,4 @@
|
||||
//===- TypeTableBuilder.h ----------------------------------------*- C++-*-===//
|
||||
//===- MergingTypeTableBuilder.h ---------------------------------*- C++-*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -7,8 +7,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPETABLEBUILDER_H
|
||||
#define LLVM_DEBUGINFO_CODEVIEW_TYPETABLEBUILDER_H
|
||||
#ifndef LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H
|
||||
#define LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
@ -31,7 +31,7 @@ namespace codeview {
|
||||
class ContinuationRecordBuilder;
|
||||
class TypeHasher;
|
||||
|
||||
class TypeTableBuilder : public TypeCollection {
|
||||
class MergingTypeTableBuilder : public TypeCollection {
|
||||
|
||||
BumpPtrAllocator &RecordStorage;
|
||||
SimpleTypeSerializer SimpleSerializer;
|
||||
@ -43,8 +43,8 @@ class TypeTableBuilder : public TypeCollection {
|
||||
SmallVector<ArrayRef<uint8_t>, 2> SeenRecords;
|
||||
|
||||
public:
|
||||
explicit TypeTableBuilder(BumpPtrAllocator &Storage, bool Hash = true);
|
||||
~TypeTableBuilder();
|
||||
explicit MergingTypeTableBuilder(BumpPtrAllocator &Storage);
|
||||
~MergingTypeTableBuilder();
|
||||
|
||||
// TypeTableCollection overrides
|
||||
Optional<TypeIndex> getFirst() override;
|
||||
@ -74,4 +74,4 @@ public:
|
||||
} // end namespace codeview
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_DEBUGINFO_CODEVIEW_TYPETABLEBUILDER_H
|
||||
#endif // LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H
|
@ -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 &Dest,
|
||||
///
|
||||
/// \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 &Dest, ArrayRef<TypeIndex> Types,
|
||||
///
|
||||
/// \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);
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
@ -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 {
|
||||
|
101
lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp
Normal file
101
lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp
Normal file
@ -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;
|
||||
}
|
@ -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
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===- TypeSerialzier.cpp -------------------------------------------------===//
|
||||
//===- MergingTypeTableBuilder.cpp ----------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -7,7 +7,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
|
||||
#include "llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/DenseSet.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
@ -130,32 +130,31 @@ TypeIndex TypeHasher::getOrCreateRecord(ArrayRef<uint8_t> &Record,
|
||||
return Hashed->Index;
|
||||
}
|
||||
|
||||
TypeIndex TypeTableBuilder::nextTypeIndex() const {
|
||||
TypeIndex MergingTypeTableBuilder::nextTypeIndex() const {
|
||||
return TypeIndex::fromArrayIndex(SeenRecords.size());
|
||||
}
|
||||
|
||||
TypeTableBuilder::TypeTableBuilder(BumpPtrAllocator &Storage, bool Hash)
|
||||
MergingTypeTableBuilder::MergingTypeTableBuilder(BumpPtrAllocator &Storage)
|
||||
: RecordStorage(Storage) {
|
||||
if (Hash)
|
||||
Hasher = llvm::make_unique<TypeHasher>(Storage);
|
||||
Hasher = llvm::make_unique<TypeHasher>(Storage);
|
||||
}
|
||||
|
||||
TypeTableBuilder::~TypeTableBuilder() = default;
|
||||
MergingTypeTableBuilder::~MergingTypeTableBuilder() = default;
|
||||
|
||||
Optional<TypeIndex> TypeTableBuilder::getFirst() {
|
||||
Optional<TypeIndex> MergingTypeTableBuilder::getFirst() {
|
||||
if (empty())
|
||||
return None;
|
||||
|
||||
return TypeIndex(TypeIndex::FirstNonSimpleIndex);
|
||||
}
|
||||
|
||||
Optional<TypeIndex> TypeTableBuilder::getNext(TypeIndex Prev) {
|
||||
Optional<TypeIndex> MergingTypeTableBuilder::getNext(TypeIndex Prev) {
|
||||
if (++Prev == nextTypeIndex())
|
||||
return None;
|
||||
return Prev;
|
||||
}
|
||||
|
||||
CVType TypeTableBuilder::getType(TypeIndex Index) {
|
||||
CVType MergingTypeTableBuilder::getType(TypeIndex Index) {
|
||||
CVType Type;
|
||||
Type.RecordData = SeenRecords[Index.toArrayIndex()];
|
||||
const RecordPrefix *P =
|
||||
@ -164,48 +163,40 @@ CVType TypeTableBuilder::getType(TypeIndex Index) {
|
||||
return Type;
|
||||
}
|
||||
|
||||
StringRef TypeTableBuilder::getTypeName(TypeIndex Index) {
|
||||
StringRef MergingTypeTableBuilder::getTypeName(TypeIndex Index) {
|
||||
llvm_unreachable("Method not implemented");
|
||||
}
|
||||
|
||||
bool TypeTableBuilder::contains(TypeIndex Index) {
|
||||
bool MergingTypeTableBuilder::contains(TypeIndex Index) {
|
||||
if (Index.isSimple() || Index.isNoneType())
|
||||
return false;
|
||||
|
||||
return Index.toArrayIndex() < SeenRecords.size();
|
||||
}
|
||||
|
||||
uint32_t TypeTableBuilder::size() { return SeenRecords.size(); }
|
||||
uint32_t MergingTypeTableBuilder::size() { return SeenRecords.size(); }
|
||||
|
||||
uint32_t TypeTableBuilder::capacity() { return SeenRecords.size(); }
|
||||
uint32_t MergingTypeTableBuilder::capacity() { return SeenRecords.size(); }
|
||||
|
||||
ArrayRef<ArrayRef<uint8_t>> TypeTableBuilder::records() const {
|
||||
ArrayRef<ArrayRef<uint8_t>> MergingTypeTableBuilder::records() const {
|
||||
return SeenRecords;
|
||||
}
|
||||
|
||||
void TypeTableBuilder::reset() {
|
||||
if (Hasher)
|
||||
Hasher->reset();
|
||||
void MergingTypeTableBuilder::reset() {
|
||||
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
|
||||
MergingTypeTableBuilder::insertRecordBytes(ArrayRef<uint8_t> &Record) {
|
||||
TypeIndex ActualTI = Hasher->getOrCreateRecord(Record, nextTypeIndex());
|
||||
if (nextTypeIndex() == ActualTI)
|
||||
SeenRecords.push_back(Record);
|
||||
return ActualTI;
|
||||
}
|
||||
|
||||
TypeIndex TypeTableBuilder::insertRecord(ContinuationRecordBuilder &Builder) {
|
||||
TypeIndex
|
||||
MergingTypeTableBuilder::insertRecord(ContinuationRecordBuilder &Builder) {
|
||||
TypeIndex TI;
|
||||
auto Fragments = Builder.end(nextTypeIndex());
|
||||
assert(!Fragments.empty());
|
@ -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(TypeIndex &Idx) {
|
||||
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(TypeTableBuilder &Dest,
|
||||
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(const CVTypeArray &Types) {
|
||||
}
|
||||
|
||||
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(RemappedType &Record,
|
||||
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(TypeTableBuilder &Dest,
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -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 LeafRecordImpl : public LeafRecordBase {
|
||||
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<FieldListRecord> : public LeafRecordBase {
|
||||
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>::fromCodeViewRecord(CVType Type) {
|
||||
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::fromCodeViewRecord(CVType Type) {
|
||||
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<uint8_t> DebugT) {
|
||||
|
||||
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);
|
||||
|
@ -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) {
|
||||
|
@ -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(StringRef Label, uint32_t FileOffset) {
|
||||
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) {
|
||||
|
@ -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 object::ObjectFile *Obj,
|
||||
|
||||
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
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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, InnerChunk) {
|
||||
}
|
||||
|
||||
TEST_F(RandomAccessVisitorTest, CrossChunkName) {
|
||||
TypeTableBuilder Builder(GlobalState->Allocator);
|
||||
AppendingTypeTableBuilder Builder(GlobalState->Allocator);
|
||||
|
||||
// TypeIndex 0
|
||||
ClassRecord Class(TypeRecordKind::Class);
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user