From da4e17d827c444bbbcceb08d577c528020d4d959 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 16 Apr 2021 17:55:35 -0700 Subject: LegalizeJSInterface: Remove illegal imports once they are no longer used (#3815) This prevents used imports which also happen to have duplicate names and therefore cannot be provided by wasm (JS is happen to fill these in with polymorphic JS functions). I noticed this when working on emscripten and directly hooking modules together. I was seeing failures, but not in release builds (because wasm-opt would mop these up in release builds). --- test/lld/duplicate_imports.wat.out | 3 +-- test/passes/legalize-js-interface-minimally.txt | 3 +-- test/passes/legalize-js-interface_all-features.txt | 5 +---- 3 files changed, 3 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/lld/duplicate_imports.wat.out b/test/lld/duplicate_imports.wat.out index 221592373..3160d1dc2 100644 --- a/test/lld/duplicate_imports.wat.out +++ b/test/lld/duplicate_imports.wat.out @@ -1,15 +1,14 @@ (module - (type $i64_=>_i32 (func (param i64) (result i32))) (type $i32_f32_f64_=>_f32 (func (param i32 f32 f64) (result f32))) (type $i32_f64_f64_=>_f32 (func (param i32 f64 f64) (result f32))) (type $2 (func)) (type $1 (func (result i32))) (type $0 (func (param i32) (result i32))) + (type $i64_=>_i32 (func (param i64) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $f32_f64_=>_f32 (func (param f32 f64) (result f32))) (type $f64_f64_=>_f32 (func (param f64 f64) (result f32))) (import "env" "puts" (func $puts1 (param i32) (result i32))) - (import "env" "puts" (func $puts2 (param i64) (result i32))) (import "env" "invoke_ffd" (func $invoke_ffd (param i32 f32 f64) (result f32))) (import "env" "invoke_ffd" (func $invoke_ffd2 (param i32 f64 f64) (result f32))) (import "env" "puts" (func $legalimport$puts2 (param i32 i32) (result i32))) diff --git a/test/passes/legalize-js-interface-minimally.txt b/test/passes/legalize-js-interface-minimally.txt index 18fb60c1f..f39a2ce84 100644 --- a/test/passes/legalize-js-interface-minimally.txt +++ b/test/passes/legalize-js-interface-minimally.txt @@ -1,11 +1,10 @@ (module (type $none_=>_i64 (func (result i64))) - (type $i64_=>_none (func (param i64))) (type $i32_=>_none (func (param i32))) + (type $i64_=>_none (func (param i64))) (type $i32_i32_=>_none (func (param i32 i32))) (type $none_=>_i32 (func (result i32))) (import "env" "imported" (func $imported (result i64))) - (import "env" "invoke_vj" (func $invoke_vj (param i64))) (import "env" "setTempRet0" (func $setTempRet0 (param i32))) (import "env" "invoke_vj" (func $legalimport$invoke_vj (param i32 i32))) (export "func" (func $func)) diff --git a/test/passes/legalize-js-interface_all-features.txt b/test/passes/legalize-js-interface_all-features.txt index 05cc43e9b..b1c57b0b8 100644 --- a/test/passes/legalize-js-interface_all-features.txt +++ b/test/passes/legalize-js-interface_all-features.txt @@ -2,12 +2,9 @@ (type $none_=>_i32 (func (result i32))) (type $none_=>_i64 (func (result i64))) (type $i32_i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32 i32))) - (type $i32_i64_i64_=>_none (func (param i32 i64 i64))) (type $none_=>_none (func)) (type $i32_=>_none (func (param i32))) - (import "env" "imported" (func $imported (result i64))) - (import "env" "other" (func $other (param i32 i64 i64))) - (import "env" "ref-func-arg" (func $ref-func-arg (result i64))) + (type $i32_i64_i64_=>_none (func (param i32 i64 i64))) (import "env" "setTempRet0" (func $setTempRet0 (param i32))) (import "env" "getTempRet0" (func $getTempRet0 (result i32))) (import "env" "imported" (func $legalimport$imported (result i32))) -- cgit v1.2.3