[Patches][RFC] What to do about bitcode streaming.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu Dec 18 15:14:33 PST 2014


Currently we support reading bitcode in 3 ways:

* Read everything upfront.
* Be lazy about reading the function bodies.
* Read the bitcode over a streaming interface.

The first two modes are commonly used and well tested. In fact the
"read everything" mode is implemented by starting lazy and calling
materializeAllPermanently.

The thirds mode is used in tree only by llvm-dis, which means that
some bugs can hide for quite some time (222505 for example). To the
best of my knowledge it is only real user is PNaCl.

It also has a disproportional code complexity. There are two virtual
interfaces (DataStreamer and MemoryObject) and they are leaky: Not all
bitcode  features are supported when streaming and there are a few "if
(LazyStreamer)" int the reader.

I have attached two patches that solve the problem with different trade-offs.

One just deletes the feature. This would make PNaCl responsible for
maintaining their own reader. I assume they will have to do it at some
point since they are looked to a fixed format, but this would make it
an immediate issue.

The other one gets most of the simplifications by adding just one
assumption: the size is known. This should be true for http with
Content-Length.

We go from 2 interfaces to 1 and that interface has a single virtual
method. There are no ifs on the data being streamed or missing
features.

It might be even possible to drop the requirement for the size to be
known: Replace the call to AtEndOfStream by just trying to read more
and checking if it failed, but that is a bit more than I wanted to do
for this.

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: known-size.patch
Type: text/x-patch
Size: 40362 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141218/43f5768b/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: remove-data-streamer.patch
Type: text/x-patch
Size: 39216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141218/43f5768b/attachment-0001.bin>


More information about the llvm-commits mailing list