diff options
author | Jérôme Vouillon <jerome.vouillon@gmail.com> | 2023-07-17 18:22:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-17 09:22:49 -0700 |
commit | a715c5f344d170c469dddd1c4d7852fa79dc2f06 (patch) | |
tree | c50f41b17f59fd99dbce0ee64a076437bfd57f45 /test/lit/merge | |
parent | 2fe4e6a7ac0f8aafe80555b91f3dec9190ad917f (diff) | |
download | binaryen-a715c5f344d170c469dddd1c4d7852fa79dc2f06.tar.gz binaryen-a715c5f344d170c469dddd1c4d7852fa79dc2f06.tar.bz2 binaryen-a715c5f344d170c469dddd1c4d7852fa79dc2f06.zip |
[wasm-merge] Handle chains of import/export (#5813)
When a module item is imported and directly reexported by an
intermediate module, we need to perform several name lookups and use its
name in the initial module rather than the intermediate name when fusing
imports and exports.
Diffstat (limited to 'test/lit/merge')
-rw-r--r-- | test/lit/merge/chain.wat | 24 | ||||
-rw-r--r-- | test/lit/merge/chain.wat.second | 4 | ||||
-rw-r--r-- | test/lit/merge/chain.wat.third | 4 | ||||
-rw-r--r-- | test/lit/merge/import_cycle.wat | 16 | ||||
-rw-r--r-- | test/lit/merge/import_cycle.wat.second | 4 |
5 files changed, 52 insertions, 0 deletions
diff --git a/test/lit/merge/chain.wat b/test/lit/merge/chain.wat new file mode 100644 index 000000000..f87914931 --- /dev/null +++ b/test/lit/merge/chain.wat @@ -0,0 +1,24 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. +;; RUN: wasm-merge %s first %s.second second %s.third third --rename-export-conflicts -all -S -o - | filecheck %s + +;; Test chains of imports / exports: the first module export a function, +;; which is reexported by the second and imported by the third. + +(module + (func (export "f")) +) +;; CHECK: (type $none_=>_none (func)) + +;; CHECK: (export "f" (func $0)) + +;; CHECK: (export "g" (func $0)) + +;; CHECK: (export "h" (func $0_2)) + +;; CHECK: (func $0 (type $none_=>_none) +;; CHECK-NEXT: (nop) +;; CHECK-NEXT: ) + +;; CHECK: (func $0_2 (type $none_=>_none) +;; CHECK-NEXT: (call $0) +;; CHECK-NEXT: ) diff --git a/test/lit/merge/chain.wat.second b/test/lit/merge/chain.wat.second new file mode 100644 index 000000000..dae1ace36 --- /dev/null +++ b/test/lit/merge/chain.wat.second @@ -0,0 +1,4 @@ +(module + (import "first" "f" (func $f)) + (export "g" (func $f)) +) diff --git a/test/lit/merge/chain.wat.third b/test/lit/merge/chain.wat.third new file mode 100644 index 000000000..cffbe5ba6 --- /dev/null +++ b/test/lit/merge/chain.wat.third @@ -0,0 +1,4 @@ +(module + (import "second" "g" (func $g)) + (func (export "h") (call $g)) +) diff --git a/test/lit/merge/import_cycle.wat b/test/lit/merge/import_cycle.wat new file mode 100644 index 000000000..0261eabc5 --- /dev/null +++ b/test/lit/merge/import_cycle.wat @@ -0,0 +1,16 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. +;; RUN: wasm-merge %s first %s.second second -S -o - | filecheck %s + +;; Test that wasm-merge terminates when there are importation cycles + +(module + ;; CHECK: (type $none_=>_none (func)) + + ;; CHECK: (import "second" "g" (func $f)) + (import "second" "g" (func $f)) + ;; CHECK: (import "first" "f" (func $f_1)) + + ;; CHECK: (export "f" (func $f_1)) + (export "f" (func $f)) +) +;; CHECK: (export "g" (func $f)) diff --git a/test/lit/merge/import_cycle.wat.second b/test/lit/merge/import_cycle.wat.second new file mode 100644 index 000000000..dae1ace36 --- /dev/null +++ b/test/lit/merge/import_cycle.wat.second @@ -0,0 +1,4 @@ +(module + (import "first" "f" (func $f)) + (export "g" (func $f)) +) |