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"); } 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)) {