From edbae93e0265c13136276d2a30cd9ba8766b3c53 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 6 Nov 2025 16:03:37 -0800 Subject: [PATCH 1/2] fix --- src/tools/fuzzing/fuzzing.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 02dba6d7962..a5cd11202f3 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -323,8 +323,11 @@ void TranslateToFuzzReader::pickPasses(OptimizationOptions& options) { // Prune things that error in JS if we call them (like SIMD), some of the // time. This alters the wasm/JS boundary quite a lot, so testing both forms - // is useful. - if (oneIn(2)) { + // is useful. Note that we do not do this if there is an imported module, + // because in that case legalization could alter the contract between the two + // (that is, if the first module has an i64 param, we must call it like that, + // and not as two i32s which we'd get after legalization). + if (!importedModule && oneIn(2)) { options.passes.push_back("legalize-and-prune-js-interface"); } From 06d84bae1515527047c153ffde71afd8e4f2f2c4 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 7 Nov 2025 15:40:53 -0800 Subject: [PATCH 2/2] Pick passes *after* setting flags, so we can see the flags --- src/tools/wasm-opt.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp index ec3bafa03e7..310544c9451 100644 --- a/src/tools/wasm-opt.cpp +++ b/src/tools/wasm-opt.cpp @@ -346,15 +346,15 @@ For more on how to optimize effectively, see if (translateToFuzz) { TranslateToFuzzReader reader( wasm, options.extra["infile"], options.passOptions.closedWorld); - if (fuzzPasses) { - reader.pickPasses(options); - } reader.setAllowMemory(fuzzMemory); reader.setAllowOOB(fuzzOOB); reader.setPreserveImportsAndExports(fuzzPreserveImportsAndExports); if (!fuzzImport.empty()) { reader.setImportedModule(fuzzImport); } + if (fuzzPasses) { + reader.pickPasses(options); + } reader.build(); if (options.passOptions.validate) { if (!WasmValidator().validate(wasm, options.passOptions)) {