This is an archive of the discontinued LLVM Phabricator instance.

[llvm-reduce] Allow writing temporary files as bitcode.
ClosedPublic

Authored by fhahn on Nov 14 2021, 11:32 AM.

Details

Summary

Textual LLVM IR files are much bigger and take longer to write to disk.
To avoid the extra cost incurred by serializing to text, this patch adds
an option to save temporary files as bitcode instead.

IMO writing bitcode would ideally be the default, as it is more
efficient and for most uses cases the temporary files will likely be
consumed by other LLVM tools that support bitcode.

But using textual IR allows for convenient use of FileCheck in the
tests, so all test would need updating.

I am also not sure how to best add a unit test using bitcode temporary
files. Python script that somehow also takes the patch to llvm-as as
argument somehow?

Diff Detail

Event Timeline

fhahn requested review of this revision.Nov 14 2021, 11:32 AM
fhahn created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptNov 14 2021, 11:32 AM
aeubanks accepted this revision.Nov 15 2021, 8:56 AM
This revision is now accepted and ready to land.Nov 15 2021, 8:56 AM

Would be good to have some testing - I guess it might look like the testing that was done before it was switched over to FileCheck - but I forget /exactly/ how awkward that was.

fhahn added a comment.Nov 15 2021, 9:07 AM

Would be good to have some testing - I guess it might look like the testing that was done before it was switched over to FileCheck - but I forget /exactly/ how awkward that was.

There are a couple of tests that still use a python script from the Inputs directory. But I am not sure how to pass the path to llvm-as to the script? :(

Would be good to have some testing - I guess it might look like the testing that was done before it was switched over to FileCheck - but I forget /exactly/ how awkward that was.

There are a couple of tests that still use a python script from the Inputs directory. But I am not sure how to pass the path to llvm-as to the script? :(

If the script took the path as an argument, then the test would pass the argument via --test-arg llvm-as - I think lit will do the substitution there...

fhahn updated this revision to Diff 387569.Nov 16 2021, 3:57 AM

Would be good to have some testing - I guess it might look like the testing that was done before it was switched over to FileCheck - but I forget /exactly/ how awkward that was.

There are a couple of tests that still use a python script from the Inputs directory. But I am not sure how to pass the path to llvm-as to the script? :(

If the script took the path as an argument, then the test would pass the argument via --test-arg llvm-as - I think lit will do the substitution there...

Ah great, I missed that there's --test-arg to pass multipel options through to the test script. I updated the patch with a python script to run llvm-dis and then FileCheck on the output. I'm planning on landing this once the pre-commit tests come back ok.

This revision was automatically updated to reflect the committed changes.

Would be good to have some testing - I guess it might look like the testing that was done before it was switched over to FileCheck - but I forget /exactly/ how awkward that was.

There are a couple of tests that still use a python script from the Inputs directory. But I am not sure how to pass the path to llvm-as to the script? :(

If the script took the path as an argument, then the test would pass the argument via --test-arg llvm-as - I think lit will do the substitution there...

Ah great, I missed that there's --test-arg to pass multipel options through to the test script. I updated the patch with a python script to run llvm-dis and then FileCheck on the output. I'm planning on landing this once the pre-commit tests come back ok.

Nice, looks great!

Any opinions on adjusting the default?

Any opinions on adjusting the default?

Yeah, I'd be open to/probably in favor of that - as you say, most often this'll be used to reduce an llvm crash, miscompile, etc - which would be fine consuming a bitcode file.

Any opinions on adjusting the default?

Yeah, I'd be open to/probably in favor of that - as you say, most often this'll be used to reduce an llvm crash, miscompile, etc - which would be fine consuming a bitcode file.

+1, should be fine