32 using namespace llvm::msf;
33 using namespace llvm::pdb;
34 using namespace llvm::support;
37 : Msf(Msf),
Allocator(Msf.getAllocator()), Header(nullptr), Idx(StreamIdx) {
49 size_t NewSize = TypeRecordBytes + Record.
size();
50 constexpr
size_t EightKB = 8 * 1024;
51 if (NewSize / EightKB > TypeRecordBytes / EightKB || TypeRecords.empty()) {
52 TypeIndexOffsets.push_back(
57 TypeRecordBytes = NewSize;
59 TypeRecords.push_back(Record);
61 TypeHashes.push_back(*Hash);
64 Error TpiStreamBuilder::finalize() {
105 uint32_t TpiStreamBuilder::calculateHashBufferSize()
const {
106 assert((TypeRecords.size() == TypeHashes.size() || TypeHashes.empty()) &&
107 "either all or no type records should have hashes");
111 uint32_t TpiStreamBuilder::calculateIndexOffsetSize()
const {
121 calculateHashBufferSize() + calculateIndexOffsetSize();
123 if (HashStreamSize == 0)
126 auto ExpectedIndex = Msf.
addStream(HashStreamSize);
128 return ExpectedIndex.takeError();
129 HashStreamIndex = *ExpectedIndex;
130 if (!TypeHashes.empty()) {
137 reinterpret_cast<const uint8_t *>(HashBuffer.data()),
138 calculateHashBufferSize());
147 if (
auto EC = finalize())
150 auto InfoS = WritableMappedBlockStream::createIndexedStream(Layout, Buffer,
157 for (
auto Rec : TypeRecords)
162 auto HVS = WritableMappedBlockStream::createIndexedStream(
163 Layout, Buffer, HashStreamIndex, Allocator);
165 if (HashValueStream) {
170 for (
auto &IndexOffset : TypeIndexOffsets) {
Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
Error writeBytes(ArrayRef< uint8_t > Buffer)
Write the bytes specified in Buffer to the underlying stream.
Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer)
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
static const uint32_t FirstNonSimpleIndex
size_t size() const
size - Get the array size.
const uint16_t kInvalidStreamIndex
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
detail::packed_endian_specific_integral< uint32_t, little, unaligned > ulittle32_t
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
Error writeStreamRef(BinaryStreamRef Ref)
Efficiently reads all data from Ref, and writes it to this stream.
Provides write only access to a subclass of WritableBinaryStream.
Error setStreamSize(uint32_t Idx, uint32_t Size)
Update the size of an existing stream.
const uint32_t MinTpiHashBuckets
static ErrorSuccess success()
Create a success value.
Expected< uint32_t > addStream(uint32_t Size, ArrayRef< uint32_t > Blocks)
Add a stream to the MSF file with the given size, occupying the given list of blocks.
void setVersionHeader(PdbRaw_TpiVer Version)
uint32_t calculateSerializedLength()
Error finalizeMsfLayout()
void addTypeRecord(ArrayRef< uint8_t > Type, Optional< uint32_t > Hash)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
std::string Hash(const Unit &U)