This is an archive of the discontinued LLVM Phabricator instance.

Bitcode: Introduce initial multi-module reader API.
ClosedPublic

Authored by pcc on Nov 15 2016, 5:09 PM.

Details

Summary

Implement getLazyBitcodeModule() and parseBitcodeFile() in terms of it.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc updated this revision to Diff 78106.Nov 15 2016, 5:09 PM
pcc retitled this revision from to Bitcode: Introduce initial multi-module reader API..
pcc updated this object.
pcc added a reviewer: mehdi_amini.
pcc added a subscriber: llvm-commits.
mehdi_amini added inline comments.Nov 15 2016, 10:02 PM
llvm/include/llvm/Bitcode/BitcodeReader.h
48 ↗(On Diff #78106)

Can you document these two fields?

llvm/lib/Bitcode/Reader/BitcodeReader.cpp
850 ↗(On Diff #78106)

Why not in the initializer list?

6607 ↗(On Diff #78106)

I think it is used only on error, isn't it?

We may be able to pass the IdentificationBit to the BitcodeReader and have it jump there to get the ProducerIdentification only if needed.

Might not worth the effort though.

llvm/test/Bitcode/invalid.test
38 ↗(On Diff #78106)

I'm surprised by this change, is it really intended? I suspect that some of your change is losing coverage here.

(Same on most of the changes below)

pcc added inline comments.Nov 15 2016, 10:15 PM
llvm/include/llvm/Bitcode/BitcodeReader.h
48 ↗(On Diff #78106)

Will do

llvm/lib/Bitcode/Reader/BitcodeReader.cpp
850 ↗(On Diff #78106)

This field belongs to BitcodeReaderBase.

6607 ↗(On Diff #78106)

We also need to check the epoch in the identification block.

I suppose we could have two functions, one that checks the epoch and the other that pulls the producer string, but again it doesn't seem worth the effort.

llvm/test/Bitcode/invalid.test
38 ↗(On Diff #78106)

Unfortunately some of our invalid bitcode files also have an invalid block size in addition to the problem under test, so we get an error trying to skip past the module in getBitcodeModuleList().

I'll see if I can restore coverage for these, but it may be some work as it will require binary patching of our test files.

mehdi_amini added inline comments.Nov 15 2016, 10:19 PM
llvm/test/Bitcode/invalid.test
38 ↗(On Diff #78106)

Yeah that's really annoying.
Maintaining invalid bitcode file across format change is not a great situation. I'd put this in the category of "unmaintainable test", especially in the absence of a code to easily generate them.

mehdi_amini accepted this revision.Nov 15 2016, 10:20 PM
mehdi_amini edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Nov 15 2016, 10:20 PM
pcc added inline comments.Nov 16 2016, 1:54 PM
llvm/test/Bitcode/invalid.test
38 ↗(On Diff #78106)

Sounds reasonable to me.

This revision was automatically updated to reflect the committed changes.