diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2020-03-17 18:17:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-17 18:17:39 -0700 |
commit | b4a8ace5c6d7f31e6d2117529220688975b6e59b (patch) | |
tree | c87cbe94c2c936b18c0f6d9b100b26949ed285a6 /scripts/fuzz_opt.py | |
parent | 595d8a3f360b7642a82459ea0ed0a825b0dd7043 (diff) | |
download | binaryen-b4a8ace5c6d7f31e6d2117529220688975b6e59b.tar.gz binaryen-b4a8ace5c6d7f31e6d2117529220688975b6e59b.tar.bz2 binaryen-b4a8ace5c6d7f31e6d2117529220688975b6e59b.zip |
Dump initial wasts in fuzzer (#2697)
Tuple operations lower to stacky code, so round tripping from IR to
binary and back is a lossy operation. To help make diagnosing bugs
uncovered by the fuzzer easier, this change writes the original IR
generated by the fuzzer and the IR produced by optimizations to files
that can be inspected after a crash to determine exactly what IR was
emitted.
Diffstat (limited to 'scripts/fuzz_opt.py')
-rw-r--r-- | scripts/fuzz_opt.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py index b07dafe53..60552179c 100644 --- a/scripts/fuzz_opt.py +++ b/scripts/fuzz_opt.py @@ -356,7 +356,9 @@ def test_one(random_input, opts): randomize_pass_debug() randomize_feature_opts() - run([in_bin('wasm-opt'), random_input, '-ttf', '-o', 'a.wasm'] + FUZZ_OPTS + FEATURE_OPTS) + printed = run([in_bin('wasm-opt'), random_input, '-ttf', '-o', 'a.wasm'] + FUZZ_OPTS + FEATURE_OPTS + ['--print']) + with open('a.printed.wast', 'w') as f: + f.write(printed) wasm_size = os.stat('a.wasm').st_size bytes = wasm_size print('pre wasm size:', wasm_size) @@ -427,7 +429,9 @@ def test_one(random_input, opts): print('') # created a second wasm for handlers that want to look at pairs. - run([in_bin('wasm-opt'), 'a.wasm', '-o', 'b.wasm'] + opts + FUZZ_OPTS + FEATURE_OPTS) + printed = run([in_bin('wasm-opt'), 'a.wasm', '-o', 'b.wasm'] + opts + FUZZ_OPTS + FEATURE_OPTS + ['--print']) + with open('b.printed.wast', 'w') as f: + f.write(printed) wasm_size = os.stat('b.wasm').st_size bytes += wasm_size print('post wasm size:', wasm_size) |