This is an archive of the discontinued LLVM Phabricator instance.

Add flag to ArchiveWriter to test GNU64 format more efficiently
ClosedPublic

Authored by jakehehrlich on Nov 29 2017, 5:07 PM.

Details

Summary

Even with the sparse file optimizations the SYM64 test can still be painfully slow. This unnecessarily slows down devs. It's critical that we test that the switch to the SYM64 format occurs at 4GB but there isn't any better of a way to fake the size of the file than sparse files. This change introduces a flag that allows the cutoff to be arbitrarily set to whatever power of two is desired. The flag is hidden as it really isn't meant to be used outside this one test. This is unfortunate but appears necessary, at least until the average hard drive is much faster.

The changes to the test require some explanation. Prior to this change we knew that the SYM64 format was being used because the file was simply too large to have validly handled this case if the SYM64 format were not used. To ensure that the SYM64 format is still being used I am grepping the file for "SYM64". Without changing the filename however this would be pointless because "SYM64" would occur in the file either way. So the filename of the test is also changed in order to avoid this issue.

Diff Detail

Repository
rL LLVM

Event Timeline

jakehehrlich created this revision.Nov 29 2017, 5:07 PM
ruiu added a subscriber: ruiu.Nov 29 2017, 5:20 PM
ruiu added inline comments.
include/llvm/Object/ArchiveWriter.h
41–45 ↗(On Diff #124857)

Instead of adding a new parameter, can't you just pass K_GNU64 as a kind?

tools/llvm-ar/llvm-ar.cpp
102 ↗(On Diff #124857)

and change this to ForceGnu64 or something.

pcc added inline comments.Nov 29 2017, 5:30 PM
tools/llvm-ar/llvm-ar.cpp
102 ↗(On Diff #124857)

If this flag is only meant to be used in one test, perhaps it would be better to move it into ArchiveWriter.cpp? That way, we can avoid extending the interface to the archive writer.

jakehehrlich retitled this revision from Add flag to llvm-ar to test GNU64 format more efficently to Add flag to ArchiveWriter to test GNU64 format more efficiently.
  1. Removed the flag from llvm-ar. I didn't realize we could do that but it makes sense. Good idea.
  2. Added a default value to the flag so that we don't need any code to handle that.

@Rui, Just adding a flag to force SYM64 only tests half of this code and ignores the code that detects the shift so it isn't really a good test if we force the particular format.

ruiu added inline comments.Nov 30 2017, 2:47 PM
lib/Object/ArchiveWriter.cpp
38–39 ↗(On Diff #125024)

I think it improves code readability a bit if you rename this Sym64Threshold or something and make it have a value of 1<<32 instead of 32.

pcc added inline comments.Nov 30 2017, 2:48 PM
lib/Object/ArchiveWriter.cpp
490 ↗(On Diff #125024)

Do you need the .getValue() part? There should be an implicit conversion from the cl::opt to the value type (i.e. int).

  1. I agree, the name I gave the flag was ugly. I prefer Sym64Threshold, so I made that change.
  2. Added the comment
  3. Removed getValue()
ruiu accepted this revision.Nov 30 2017, 4:38 PM

LGTM

This revision is now accepted and ready to land.Nov 30 2017, 4:38 PM
This revision was automatically updated to reflect the committed changes.
llvm/trunk/test/Object/archive-GNU64-write.test