From 8dbe3629a09a754464f1420ce3059676c986090a Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Fri, 27 May 2016 01:54:44 +0000 Subject: [codeview,pdb] Try really hard to conserve memory when reading. PDBs can be extremely large. We're already mapping the entire PDB into the process's address space, but to make matters worse the blocks of the PDB are not arranged contiguously. So, when we have something like an array or a string embedded into the stream, we have to make a copy. Since it's convenient to use traditional data structures to iterate and manipulate these records, we need the memory to be contiguous. As a result of this, we were using roughly twice as much memory as the file size of the PDB, because every stream was copied out and re-stitched together contiguously. This patch addresses this by improving the MappedBlockStream to allocate from a BumpPtrAllocator only when a read requires a discontiguous read. Furthermore, it introduces some data structures backed by a stream which can iterate over both fixed and variable length records of a PDB. Since everything is backed by a stream and not a buffer, we can read almost everything from the PDB with zero copies. Differential Revision: http://reviews.llvm.org/D20654 Reviewed By: ruiu llvm-svn: 270951 --- llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp') diff --git a/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp index c359e7757d0..38d3f2f23e3 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp @@ -32,17 +32,17 @@ Error ModStream::reload() { return llvm::make_error(raw_error_code::corrupt_file, "Module has both C11 and C13 line info"); - if (auto EC = SymbolsSubstream.initialize(Reader, SymbolSize)) + if (auto EC = SymbolsSubstream.load(Reader, SymbolSize)) return EC; - if (auto EC = LinesSubstream.initialize(Reader, C11Size)) + if (auto EC = Reader.readStreamRef(LinesSubstream, C11Size)) return EC; - if (auto EC = C13LinesSubstream.initialize(Reader, C13Size)) + if (auto EC = Reader.readStreamRef(C13LinesSubstream, C13Size)) return EC; uint32_t GlobalRefsSize; if (auto EC = Reader.readInteger(GlobalRefsSize)) return EC; - if (auto EC = GlobalRefsSubstream.initialize(Reader, GlobalRefsSize)) + if (auto EC = Reader.readStreamRef(GlobalRefsSubstream, GlobalRefsSize)) return EC; if (Reader.bytesRemaining() > 0) return llvm::make_error(raw_error_code::corrupt_file, -- cgit v1.2.3