Skip to content

Commit

Permalink
[PDB] Move stream index tracking to GSIStreamBuilder
Browse files Browse the repository at this point in the history
The GSIHashStreamBuilder doesn't need to know the stream index.
Standardize the naming (Idx -> Index in public APIs).
  • Loading branch information
rnk committed May 5, 2020
1 parent 93f7e52 commit b7438c2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
10 changes: 6 additions & 4 deletions llvm/include/llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h
Expand Up @@ -51,9 +51,9 @@ class GSIStreamBuilder {

Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer);

uint32_t getPublicsStreamIndex() const;
uint32_t getGlobalsStreamIndex() const;
uint32_t getRecordStreamIdx() const { return RecordStreamIdx; }
uint32_t getPublicsStreamIndex() const { return PublicsStreamIndex; }
uint32_t getGlobalsStreamIndex() const { return GlobalsStreamIndex; }
uint32_t getRecordStreamIndex() const { return RecordStreamIndex; }

void addPublicSymbol(const codeview::PublicSym32 &Pub);

Expand All @@ -69,7 +69,9 @@ class GSIStreamBuilder {
Error commitPublicsHashStream(WritableBinaryStreamRef Stream);
Error commitGlobalsHashStream(WritableBinaryStreamRef Stream);

uint32_t RecordStreamIdx = kInvalidStreamIndex;
uint32_t PublicsStreamIndex = kInvalidStreamIndex;
uint32_t GlobalsStreamIndex = kInvalidStreamIndex;
uint32_t RecordStreamIndex = kInvalidStreamIndex;
msf::MSFBuilder &Msf;
std::unique_ptr<GSIHashStreamBuilder> PSH;
std::unique_ptr<GSIHashStreamBuilder> GSH;
Expand Down
18 changes: 5 additions & 13 deletions llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
Expand Up @@ -49,7 +49,6 @@ struct llvm::pdb::GSIHashStreamBuilder {
};

std::vector<CVSymbol> Records;
uint32_t StreamIndex;
llvm::DenseSet<CVSymbol, SymbolDenseMapInfo> SymbolHashes;
std::vector<PSHashRecord> HashRecords;
std::array<support::ulittle32_t, (IPHR_HASH + 32) / 32> HashBitmap;
Expand Down Expand Up @@ -213,19 +212,20 @@ Error GSIStreamBuilder::finalizeMsfLayout() {
Expected<uint32_t> Idx = Msf.addStream(calculateGlobalsHashStreamSize());
if (!Idx)
return Idx.takeError();
GSH->StreamIndex = *Idx;
GlobalsStreamIndex = *Idx;

Idx = Msf.addStream(calculatePublicsHashStreamSize());
if (!Idx)
return Idx.takeError();
PSH->StreamIndex = *Idx;
PublicsStreamIndex = *Idx;

uint32_t RecordBytes =
GSH->calculateRecordByteSize() + PSH->calculateRecordByteSize();

Idx = Msf.addStream(RecordBytes);
if (!Idx)
return Idx.takeError();
RecordStreamIdx = *Idx;
RecordStreamIndex = *Idx;
return Error::success();
}

Expand Down Expand Up @@ -286,14 +286,6 @@ static std::vector<ulittle32_t> computeAddrMap(ArrayRef<CVSymbol> Records) {
return AddrMap;
}

uint32_t GSIStreamBuilder::getPublicsStreamIndex() const {
return PSH->StreamIndex;
}

uint32_t GSIStreamBuilder::getGlobalsStreamIndex() const {
return GSH->StreamIndex;
}

void GSIStreamBuilder::addPublicSymbol(const PublicSym32 &Pub) {
PSH->addSymbol(Pub, Msf);
}
Expand Down Expand Up @@ -377,7 +369,7 @@ Error GSIStreamBuilder::commit(const msf::MSFLayout &Layout,
auto PS = WritableMappedBlockStream::createIndexedStream(
Layout, Buffer, getPublicsStreamIndex(), Msf.getAllocator());
auto PRS = WritableMappedBlockStream::createIndexedStream(
Layout, Buffer, getRecordStreamIdx(), Msf.getAllocator());
Layout, Buffer, getRecordStreamIndex(), Msf.getAllocator());

if (auto EC = commitSymbolRecordStream(*PRS))
return EC;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
Expand Up @@ -144,7 +144,7 @@ Error PDBFileBuilder::finalizeMsfLayout() {
if (Dbi) {
Dbi->setPublicsStreamIndex(Gsi->getPublicsStreamIndex());
Dbi->setGlobalsStreamIndex(Gsi->getGlobalsStreamIndex());
Dbi->setSymbolRecordStreamIndex(Gsi->getRecordStreamIdx());
Dbi->setSymbolRecordStreamIndex(Gsi->getRecordStreamIndex());
}
}
if (Tpi) {
Expand Down

0 comments on commit b7438c2

Please sign in to comment.