From b4a8ace5c6d7f31e6d2117529220688975b6e59b Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Tue, 17 Mar 2020 18:17:39 -0700 Subject: 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. --- scripts/fuzz_opt.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts/fuzz_opt.py') 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) -- cgit v1.2.3