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

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed Dec 24 08:49:32 PST 2014


> That is to remove some calls to getSize()? Is there any expectation that
> getPointer() will always a pointer within a contiguous region of memory?
> That is, getPointer() is non-virtual and always refers to the Data field,
> but the overriding implementation could still dynamically grow some buffer
> and change Data to point to a new buffer (could that be "protected"
> instead?)?

I think it would fail. Clang does things like

* readRecord (... &Blob);
* Save a pointer to Blob.
* readRecord (...&Blob)

It should be possible to use a list of buffers and add a
getPointerImpl virtual if absolutely necessary, but see bellow.

> *) It looks like gzip encoded files will have content-length set to the size
> of the *gzipped* body, not the size of the original bitcode:
> http://stackoverflow.com/questions/3819280/content-length-when-using-http-compression.
> So we'll need to be careful and treat that as "unknown", which is a bit
> unfortunate because gzip helps reduce bandwidth requirements.

You should try removing the need for getSize, but if that fails, this
is so pnacl specific, can't you wrap the bitcode in with a header
including the size (this would be kept in the PNaCl tree. It would
just be another implementation of the DataStream).

> Not quite clear to me that this is the same. Do we have a test of llvm-dis
> w/ files that have a bitcode wrapper + misc data surrounding the true
> bitcode contents?

We have tests that have a wrapper.

> The old dropLeadingBytes would track how many bytes were skipped so that
> later, reading address N would mean reading N + BytesSkipped. It also
> subtracted the skipped bytes from BytesRead, and I haven't looked closely
> enough to see if there is similar state being tracked anymore.

There isn't. The point is precisely that it is not needed.

> @@ -218,18 +214,13 @@ public:
>    void freeState();
>
>    bool canSkipToPos(size_t pos) const {
> -    // pos can be skipped to if it is a valid address or one byte past the
> end.
> -    return pos == 0 || BitStream->getBitcodeBytes().isValidAddress(
> -        static_cast<uint64_t>(pos - 1));
> +    size_t Size = BitStream->getSize();
> +    return pos < Size;
>    }
>
> Is the "pos can be skipped ... or one byte past the end" behavior still
> needed, or was it some artifact of how isValidAddress worked?

Doesn't show up on check-all or a lto bootstrap.


I have looked at this a bit more, and now I have a more serious issue
with the current state of trunk. Check the small attached patch. It
just changes llc to use lazy reading of function bodies (not even lazy
streaming). With that patch, llc fails with verifier check failures or
assertions if the verifier is disabled.

So, codegen cannot handle not reading all bodies upfront. How can
PNaCl be getting any improvements from this? I understand that codegen
of a function at a time is something you might want to add a some
point, but lazy streaming was added in Feb 6 22:30:29 2012 and we
still don't have it.

It seems the best thing to do is delete this. It can always come back
if it has a clean implementation and is actually useful (even if only
at -O0).

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: text/x-patch
Size: 484 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141224/fafdb60c/attachment.bin>


More information about the llvm-commits mailing list