This is an archive of the discontinued LLVM Phabricator instance.

Pre compute the tail of the archive
ClosedPublic

Authored by rafael on Sep 22 2017, 2:47 PM.

Details

Reviewers
jakehehrlich
ruiu
Summary

An archive looks like

<header>
<symbol table>
<tail>

The symbol table refers to offsets in the tail. A complication is that we would like to support symbol tables that use 64 bit offsets if it turns out that any of the offsets is too big.

This patch changes the archive writer to first compute the tail. We cannot just compute one bit StringRef since that would require reading every member upfront, but we can represent it as a series of StringRefs.

Having done that it is much easier to compute the symbol table and all offsets are computed before it is written. With this if there is an accounting problem it will show up with a regular symbol table, not just when a 64 bit one is needed.

This should help simplify D36812.

Diff Detail

Event Timeline

rafael created this revision.Sep 22 2017, 2:47 PM

Trying to get phab to send email

ruiu added inline comments.Sep 26 2017, 5:30 PM
lib/Object/ArchiveWriter.cpp
254

It looks like you are using StringSaver only to save this member contents. You may be able to remove StringSaver if you change this to std::string.

ruiu added inline comments.Sep 26 2017, 5:31 PM
lib/Object/ArchiveWriter.cpp
311–318

This is not new code, but I wonder if we can just align all members to 8 bytes. Is there any reason not to do that?

rafael updated this revision to Diff 117457.Oct 2 2017, 6:01 PM

Rename missing places. Guard against std::thread::hardware_concurrency returning 0.

Rename missing places. Guard against std::thread::hardware_concurrency returning 0.

Sorry, uploaded the patch to the wrong review.

Used std::string instead of a StringSaver.

ruiu accepted this revision.Oct 3 2017, 12:45 PM

LGTM

This revision is now accepted and ready to land.Oct 3 2017, 12:45 PM
rafael closed this revision.Oct 3 2017, 2:02 PM

r314844.