This is an archive of the discontinued LLVM Phabricator instance.

llvm-isel-fuzzer: Handle a subset of backend flags in the executable name
ClosedPublic

Authored by bogner on Sep 5 2017, 4:06 PM.

Details

Summary

Here we add a secondary option parser to llvm-isel-fuzzer (and provide
it for use with other fuzzers). With this, you can copy the fuzzer to
a name like llvm-isel-fuzzer:aarch64-gisel for a fuzzer that fuzzer
AArch64 with GlobalISel enabled, or fuzzer:x86_64 to fuzz x86, with no
flags required. This should be useful for running these in OSS-Fuzz.

Note that this handrolls a subset of cl::opts to recognize, rather
than embedding a complete command parser for argv[0]. If we find we
really need the flexibility of handling arbitrary options at some
point we can rethink this.

Diff Detail

Event Timeline

bogner created this revision.Sep 5 2017, 4:06 PM
vsk added inline comments.Sep 5 2017, 4:14 PM
lib/FuzzMutate/FuzzerCLI.cpp
44

If there's a fuzzer writeup in llvm/docs, it might be worth mentioning these option names in it.

61

We might be able to get a tighter test by printing out the args here, then checking for them in filecheck.

Pro: default behaviors (e.g gisel => -O0) become clearer.
Con: This makes the fuzzer stdout a bit more crowded.

kcc edited edge metadata.

this handrolls a subset of cl::opts to recognize

This sounds good.

But there should be some way to find out which "handrolled subsets" are available.

bogner added a comment.Sep 5 2017, 5:18 PM
In D37495#861652, @kcc wrote:

this handrolls a subset of cl::opts to recognize

This sounds good.

But there should be some way to find out which "handrolled subsets" are available.

Sure. I've been planning to write up some overview type docs (possibly pulling the Fuzzing components of LLVM parts out of the libFuzzer docs and expanding on them). I think that's probably the right place for this.

kcc added a comment.Sep 5 2017, 5:25 PM

some overview type docs (possibly pulling the Fuzzing components of LLVM parts out of the libFuzzer docs

+1
This should really be a separate doc now.

kcc added inline comments.Sep 5 2017, 7:57 PM
lib/FuzzMutate/FuzzerCLI.cpp
61

I would actually request that we print "Args" to errs() here, with some prefix, e.g.:
"Flags deducted from <BinaryName>: -foo -bar"

This way it will be trivial to test this and to manually verify the desired effect.

kcc added a comment.Oct 10 2017, 12:30 PM

ping. :)
I'd like to add this target to oss-fuzz before the llvm dev meeting (sooooon!)

In D37495#893677, @kcc wrote:

I'd like to add this target to oss-fuzz before the llvm dev meeting (sooooon!)

Oops, I'd started writing up some docs and then got distracted and never looped back to this. I'll commit today or tomorrow.

bogner accepted this revision.Oct 11 2017, 7:29 PM
bogner marked 3 inline comments as done.

Committed with the requested changes in r315545

lib/FuzzMutate/FuzzerCLI.cpp
44

I've added some docs in FuzzingLLVM in r315544, and I'll add some notes about this in those docs when I commit.

61

I'll make these print to stderr with a note like "<Binary name>: Injected args: ..."

This revision is now accepted and ready to land.Oct 11 2017, 7:29 PM
bogner closed this revision.Oct 11 2017, 7:29 PM
bogner marked 2 inline comments as done.

Note: This had issues on windows, so I changed it to use '=' instead of ':' and recommitted in 315557