[PATCH] D26068: Support: Simplify MemoryObject interface.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 28 02:14:43 PDT 2016


pcc created this revision.
pcc added a reviewer: mehdi_amini.
pcc added a subscriber: llvm-commits.

This simplifies the existing MemoryObject interface to the following:

/// Returns a reference to a buffer containing all of the data read so far.
ArrayRef<uint8_t> getBuffer() const;

/// Try to extend the buffer held by this MemoryObject to at least Size
/// bytes. Calling this function invalidates any buffer previously
/// returned by getBuffer().
///
/// @result True if successful.
bool tryExtendTo(uint64_t Size);

/// Returns the size of the region in bytes.  (The region is contiguous, so
/// the highest valid address of the region is getExtent() - 1). Calling this
/// function invalidates any buffer previously returned by getBuffer().
///
/// @result The size of the region.
uint64_t getExtent();

This interface is not only smaller, but it results in better performance
likely as a result of avoiding a virtual call and a copy for each word we
read. I observed a performance improvement of 7.5% when using "llvm-dis
-disable-output" and 3% when using "opt -disable-output -disable-verify"
to read a bitcode file of size ~11MB (median of 100 runs).


https://reviews.llvm.org/D26068

Files:
  llvm/include/llvm/Bitcode/BitstreamReader.h
  llvm/include/llvm/Support/MemoryObject.h
  llvm/include/llvm/Support/StreamingMemoryObject.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Support/StreamingMemoryObject.cpp
  llvm/unittests/Support/StreamingMemoryObjectTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26068.76173.patch
Type: text/x-patch
Size: 16526 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161028/883add63/attachment.bin>


More information about the llvm-commits mailing list