From fdbf0a5af805b764927bd8b38da89ddffc67f531 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 25 Mar 2016 14:40:18 +0000 Subject: Bitcode: Collect all MDString records into a single blob Optimize output of MDStrings in bitcode. This emits them in big blocks (currently 1024) in a pair of records: - BULK_STRING_SIZES: the sizes of the strings in the block, and - BULK_STRING_DATA: a single blob, which is the concatenation of all the strings. Inspired by Mehdi's similar patch, http://reviews.llvm.org/D18342, this should (a) slightly reduce bitcode size, since there is less record overhead, and (b) greatly improve reading speed, since blobs are super cheap to deserialize. I needed to add support for blobs to streaming input to get the test suite passing. - StreamingMemoryObject::getPointer reads ahead and returns the address of the blob. - To avoid a possible reallocation of StreamingMemoryObject::Bytes, BitstreamCursor::readRecord needs to move the call to JumpToEnd forward so that getPointer is the last bitstream operation. llvm-svn: 264409 --- llvm/lib/Support/StreamingMemoryObject.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'llvm/lib/Support/StreamingMemoryObject.cpp') diff --git a/llvm/lib/Support/StreamingMemoryObject.cpp b/llvm/lib/Support/StreamingMemoryObject.cpp index 5a44e624eb8..fb566179486 100644 --- a/llvm/lib/Support/StreamingMemoryObject.cpp +++ b/llvm/lib/Support/StreamingMemoryObject.cpp @@ -104,6 +104,12 @@ uint64_t StreamingMemoryObject::readBytes(uint8_t *Buf, uint64_t Size, return Size; } +const uint8_t *StreamingMemoryObject::getPointer(uint64_t Address, + uint64_t Size) const { + fetchToPos(Address + Size - 1); + return &Bytes[Address + BytesSkipped]; +} + bool StreamingMemoryObject::dropLeadingBytes(size_t s) { if (BytesRead < s) return true; BytesSkipped = s; -- cgit v1.2.3