diff options
author | Zachary Turner <zturner@google.com> | 2017-08-09 04:23:25 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-08-09 04:23:25 +0000 |
commit | 946204c83e74434568d4fbf6174d2da48215efd4 (patch) | |
tree | a8b81732d59c768e9a8df749c6b8b3c806e3eb0b /llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp | |
parent | 35cb4f84a4b5f9509256ff872f14b1c5dafc41e2 (diff) | |
download | bcm5719-llvm-946204c83e74434568d4fbf6174d2da48215efd4.tar.gz bcm5719-llvm-946204c83e74434568d4fbf6174d2da48215efd4.zip |
[PDB] Merge Global and Publics Builders.
The publics stream and globals stream are very similar. They both
contain a list of hash buckets that refer into a single shared stream,
the symbol record stream. Because of the need for each builder to manage
both an independent hash stream as well as a single shared record
stream, making the two builders be independent entities is not the right
design. This patch merges them into a single class, of which only a
single instance is needed to create all 3 streams. PublicsStreamBuilder
and GlobalsStreamBuilder are now merged into the single GSIStreamBuilder
class, which writes all 3 streams at once.
Note that this patch does not contain any functionality change. So we're
still not yet writing any records to the globals stream. All we're doing
is making it so that when we do start writing records to the globals,
this refactor won't have to be part of that patch.
Differential Revision: https://reviews.llvm.org/D36489
llvm-svn: 310438
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp | 51 |
1 files changed, 12 insertions, 39 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp index 09e86bf0c13..dd8e2ac8b53 100644 --- a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp @@ -15,11 +15,10 @@ #include "llvm/DebugInfo/PDB/GenericError.h" #include "llvm/DebugInfo/PDB/Native/DbiStream.h" #include "llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h" -#include "llvm/DebugInfo/PDB/Native/GlobalsStreamBuilder.h" +#include "llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h" #include "llvm/DebugInfo/PDB/Native/InfoStream.h" #include "llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h" #include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h" -#include "llvm/DebugInfo/PDB/Native/PublicsStreamBuilder.h" #include "llvm/DebugInfo/PDB/Native/RawError.h" #include "llvm/DebugInfo/PDB/Native/TpiStream.h" #include "llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h" @@ -75,16 +74,10 @@ PDBStringTableBuilder &PDBFileBuilder::getStringTableBuilder() { return Strings; } -PublicsStreamBuilder &PDBFileBuilder::getPublicsBuilder() { - if (!Publics) - Publics = llvm::make_unique<PublicsStreamBuilder>(*Msf); - return *Publics; -} - -GlobalsStreamBuilder &PDBFileBuilder::getGlobalsBuilder() { - if (!Globals) - Globals = llvm::make_unique<GlobalsStreamBuilder>(*Msf); - return *Globals; +GSIStreamBuilder &PDBFileBuilder::getGsiBuilder() { + if (!Gsi) + Gsi = llvm::make_unique<GSIStreamBuilder>(*Msf); + return *Gsi; } Error PDBFileBuilder::addNamedStream(StringRef Name, uint32_t Size) { @@ -129,22 +122,16 @@ Expected<msf::MSFLayout> PDBFileBuilder::finalizeMsfLayout() { if (auto EC = Ipi->finalizeMsfLayout()) return std::move(EC); } - if (Publics) { - if (auto EC = Publics->finalizeMsfLayout()) + if (Gsi) { + if (auto EC = Gsi->finalizeMsfLayout()) return std::move(EC); if (Dbi) { - Dbi->setPublicsStreamIndex(Publics->getStreamIndex()); - Dbi->setSymbolRecordStreamIndex(Publics->getRecordStreamIdx()); + Dbi->setPublicsStreamIndex(Gsi->getPublicsStreamIndex()); + Dbi->setGlobalsStreamIndex(Gsi->getGlobalsStreamIndex()); + Dbi->setSymbolRecordStreamIndex(Gsi->getRecordStreamIdx()); } } - if (Globals) { - if (auto EC = Globals->finalizeMsfLayout()) - return std::move(EC); - if (Dbi) - Dbi->setGlobalsStreamIndex(Globals->getStreamIndex()); - } - return Msf->build(); } @@ -251,22 +238,8 @@ Error PDBFileBuilder::commit(StringRef Filename) { return EC; } - if (Publics) { - auto PS = WritableMappedBlockStream::createIndexedStream( - Layout, Buffer, Publics->getStreamIndex(), Allocator); - auto PRS = WritableMappedBlockStream::createIndexedStream( - Layout, Buffer, Publics->getRecordStreamIdx(), Allocator); - BinaryStreamWriter PSWriter(*PS); - BinaryStreamWriter RecWriter(*PRS); - if (auto EC = Publics->commit(PSWriter, RecWriter)) - return EC; - } - - if (Globals) { - auto GS = WritableMappedBlockStream::createIndexedStream( - Layout, Buffer, Globals->getStreamIndex(), Allocator); - BinaryStreamWriter GSWriter(*GS); - if (auto EC = Globals->commit(GSWriter)) + if (Gsi) { + if (auto EC = Gsi->commit(Layout, Buffer)) return EC; } |