This is an archive of the discontinued LLVM Phabricator instance.

Bitcode: Include any strings added to the string table in the module hash.
ClosedPublic

Authored by pcc on Jul 5 2017, 3:38 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc created this revision.Jul 5 2017, 3:38 PM
tejohnson edited edge metadata.Jul 6 2017, 9:10 AM

Looks ok but a couple of clarifying questions below.

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
956 ↗(On Diff #105349)

Out of curiosity, couldn't the Hasher be updated with the contents of the StrtabBuilder when we writeModuleHash? I guess that would require finalizing the StrtabBuilder a little earlier - ah, we need to add to the StrtabBuilder when building the symtab.

llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
660 ↗(On Diff #105349)

It's unfortunate that we need to explicitly pass in the expected strtab contents rather than just using the STRTAB_BLOB, but I guess here too the issue is that the final strtab included strings that were in the symtab that we didn't have when writing the module hash?

pcc added inline comments.Jul 6 2017, 10:41 AM
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
956 ↗(On Diff #105349)

Yes, or when adding other modules to the bitcode file.

llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
660 ↗(On Diff #105349)

Right. We could also in principle teach llvm-bcanalyzer about the various records that may refer to the string table, and have it include the hashes of those strings in the hash it computes here, but that seems more complicated than called for here (for one thing, it would require multiple passes over the bitcode file).

I guess that requiring the user to provide the string table also has the side benefit of having the test verify that the string table contents are as expected.

tejohnson accepted this revision.Jul 6 2017, 10:49 AM

LGTM

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
956 ↗(On Diff #105349)

Ah, forgot about other modules.

This revision is now accepted and ready to land.Jul 6 2017, 10:49 AM
This revision was automatically updated to reflect the committed changes.