This is an archive of the discontinued LLVM Phabricator instance.

Support: Simplify MemoryObject interface.
Needs ReviewPublic

Authored by pcc on Oct 28 2016, 2:14 AM.

Details

Reviewers
mehdi_amini
Summary

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).

Event Timeline

pcc updated this revision to Diff 76173.Oct 28 2016, 2:14 AM
pcc retitled this revision from to Support: Simplify MemoryObject interface..
pcc updated this object.
pcc added a reviewer: mehdi_amini.
pcc added a subscriber: llvm-commits.