diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2020-04-24 15:51:11 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-24 15:51:11 -0700 |
commit | 12445969dc5b32cbe82b829fe8c061f5d98fcbe7 (patch) | |
tree | f9b6bd44d3b7cd7864c148a698712b32f802348e /src/tools | |
parent | 204cc7b7172d665ee731171d20995edb5897ef7d (diff) | |
download | binaryen-12445969dc5b32cbe82b829fe8c061f5d98fcbe7.tar.gz binaryen-12445969dc5b32cbe82b829fe8c061f5d98fcbe7.tar.bz2 binaryen-12445969dc5b32cbe82b829fe8c061f5d98fcbe7.zip |
Remove --fuzz-binary and simplify round trip (#2799)
Since the --roundtrip pass is more general than --fuzz-binary anyways. Also reimplements `ModuleUtils::clearModule` to use the module destructor and placement new to ensure that no members are missed.
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/wasm-opt.cpp | 39 |
1 files changed, 5 insertions, 34 deletions
diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp index 6fd3b7c8d..a215aca32 100644 --- a/src/tools/wasm-opt.cpp +++ b/src/tools/wasm-opt.cpp @@ -79,7 +79,6 @@ int main(int argc, const char* argv[]) { bool converge = false; bool fuzzExecBefore = false; bool fuzzExecAfter = false; - bool fuzzBinary = false; std::string extraFuzzCommand; bool translateToFuzz = false; bool fuzzPasses = false; @@ -127,12 +126,6 @@ int main(int argc, const char* argv[]) { [&](Options* o, const std::string& arguments) { fuzzExecBefore = fuzzExecAfter = true; }) - .add("--fuzz-binary", - "-fb", - "Convert to binary and back after optimizations and before fuzz-exec, " - "helping fuzzing find binary format bugs", - Options::Arguments::Zero, - [&](Options* o, const std::string& arguments) { fuzzBinary = true; }) .add("--extra-fuzz-command", "-efc", "An extra command to run on the output before and after optimizing. " @@ -328,28 +321,6 @@ int main(int argc, const char* argv[]) { std::cout << "[extra-fuzz-command first output:]\n" << firstOutput << '\n'; } - Module* curr = &wasm; - Module other; - - if (fuzzExecAfter && fuzzBinary) { - BufferWithRandomAccess buffer; - // write the binary - WasmBinaryWriter writer(&wasm, buffer); - writer.write(); - // read the binary - auto input = buffer.getAsChars(); - WasmBinaryBuilder parser(other, input); - parser.read(); - options.applyFeatures(other); - if (options.passOptions.validate) { - bool valid = WasmValidator().validate(other); - if (!valid) { - Fatal() << "fuzz-binary must always generate a valid module"; - } - } - curr = &other; - } - if (!options.runningPasses()) { if (!options.quiet) { std::cerr << "warning: no passes specified, not doing any work\n"; @@ -357,9 +328,9 @@ int main(int argc, const char* argv[]) { } else { BYN_TRACE("running passes...\n"); auto runPasses = [&]() { - options.runPasses(*curr); + options.runPasses(wasm); if (options.passOptions.validate) { - bool valid = WasmValidator().validate(*curr); + bool valid = WasmValidator().validate(wasm); if (!valid) { exitOnInvalidWasm("error after opts"); } @@ -371,7 +342,7 @@ int main(int argc, const char* argv[]) { // size no longer decreasing. auto getSize = [&]() { BufferWithRandomAccess buffer; - WasmBinaryWriter writer(curr, buffer); + WasmBinaryWriter writer(&wasm, buffer); writer.write(); return buffer.size(); }; @@ -389,7 +360,7 @@ int main(int argc, const char* argv[]) { } if (fuzzExecAfter) { - results.check(*curr); + results.check(wasm); } if (options.extra.count("output") == 0) { @@ -407,7 +378,7 @@ int main(int argc, const char* argv[]) { writer.setSourceMapFilename(outputSourceMapFilename); writer.setSourceMapUrl(outputSourceMapUrl); } - writer.write(*curr, options.extra["output"]); + writer.write(wasm, options.extra["output"]); if (extraFuzzCommand.size() > 0) { auto secondOutput = runCommand(extraFuzzCommand); |