Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions test/lit/wasm-split/passive-deps.wast
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: wasm-split %s -all -g -o1 %t.1.wasm -o2 %t.2.wasm --split-funcs=split
;; RUN: wasm-dis -all %t.1.wasm | filecheck %s --check-prefix PRIMARY
;; RUN: wasm-dis -all %t.2.wasm | filecheck %s --check-prefix SECONDARY

(module
;; PRIMARY: (type $0 (func))

;; PRIMARY: (global $g funcref (ref.null nofunc))
(global $g funcref (ref.null nofunc))

;; We should scan this passive element segment's data and correctly mark $g as
;; used in the primary module.
;; PRIMARY: (elem $passive-elem funcref (item (global.get $g)))
(elem $passive-elem funcref (item (global.get $g)))

;; PRIMARY: (export "global" (global $g))

;; PRIMARY: (func $keep (type $0)
;; PRIMARY-NEXT: (elem.drop $passive-elem)
;; PRIMARY-NEXT: )
(func $keep
(elem.drop $passive-elem)
)

;; SECONDARY: (type $0 (func))

;; SECONDARY: (import "primary" "global" (global $g funcref))

;; SECONDARY: (func $split (type $0)
;; SECONDARY-NEXT: (drop
;; SECONDARY-NEXT: (global.get $g)
;; SECONDARY-NEXT: )
;; SECONDARY-NEXT: )
(func $split
(drop (global.get $g))
)
)

;; PRIMARY: (module
;; PRIMARY-NEXT: (type $0 (func))
;; PRIMARY-NEXT: (global $g funcref (ref.null nofunc))
;; PRIMARY-NEXT: (elem $passive-elem funcref (item (global.get $g)))
;; PRIMARY-NEXT: (export "global" (global $g))
;; PRIMARY-NEXT: (func $keep (type $0)
;; PRIMARY-NEXT: (elem.drop $passive-elem)
;; PRIMARY-NEXT: )
;; PRIMARY-NEXT: )

;; SECONDARY: (module
;; SECONDARY-NEXT: (type $0 (func))
;; SECONDARY-NEXT: (import "primary" "global" (global $g funcref))
;; SECONDARY-NEXT: (func $split (type $0)
;; SECONDARY-NEXT: (drop
;; SECONDARY-NEXT: (global.get $g)
;; SECONDARY-NEXT: )
;; SECONDARY-NEXT: )
;; SECONDARY-NEXT: )
56 changes: 38 additions & 18 deletions test/lit/wasm-split/split-module-items.wast
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
;; This is only used in the secondary module, but segments $keep-data2 can trap
;; so it is pinned to the primary, so this will be too.
(memory $keep-memory2 1 1)
(global $keep-global i32 (i32.const 20))
(global $keep-immutable-global i32 (i32.const 20))
(global $keep-mutable-global (mut i32) (i32.const 20))
(table $keep-table 1 1 funcref)
;; This is only used in the secondary module, but segments $keep-elem2 and
;; $keep-elem3 can trap so they are pinned to the primary, so this will be too.
Expand All @@ -35,21 +36,25 @@
(data $keep-data2 (memory $keep-memory2) (i32.const 65536) "a")

(memory $split-memory 1 1)
(global $split-global i32 (i32.const 20))
(global $split-immutable-global i32 (i32.const 20))
(global $split-mutable-global (mut i32) (i32.const 20))
(table $split-table 1 1 funcref)
(tag $split-tag (param i32))
(elem $split-elem (table $split-table) (i32.const 0) funcref (item (ref.null nofunc)))
(data $split-data (memory $split-memory) (i32.const 0) "a")

(memory $shared-memory 1 1)
(global $shared-global i32 (i32.const 20))
(global $shared-immutable-global i32 (i32.const 20))
(global $shared-mutable-global (mut i32) (i32.const 20))
(table $shared-table 1 1 funcref)
(tag $shared-tag (param i32))
(elem $shared-elem (table $shared-table) (i32.const 0) funcref (item (ref.null nofunc)))
(data $shared-data (memory $shared-memory) (i32.const 0) "a")

;; PRIMARY: (global $keep-global i32 (i32.const 20))
;; PRIMARY-NEXT: (global $shared-global i32 (i32.const 20))
;; PRIMARY: (global $keep-immutable-global i32 (i32.const 20))
;; PRIMARY-NEXT: (global $keep-mutable-global (mut i32) (i32.const 20))
;; PRIMARY-NEXT: (global $shared-immutable-global i32 (i32.const 20))
;; PRIMARY-NEXT: (global $shared-mutable-global (mut i32) (i32.const 20))
;; PRIMARY-NEXT: (memory $keep-memory 1 1)
;; PRIMARY-NEXT: (memory $keep-memory2 1 1)
;; PRIMARY-NEXT: (memory $shared-memory 1 1)
Expand All @@ -73,21 +78,24 @@
;; PRIMARY-NEXT: (export "memory_1" (memory $shared-memory))
;; PRIMARY-NEXT: (export "table" (table $keep-table2))
;; PRIMARY-NEXT: (export "table_3" (table $shared-table))
;; PRIMARY-NEXT: (export "global" (global $shared-global))
;; PRIMARY-NEXT: (export "global" (global $shared-immutable-global))
;; PRIMARY-NEXT: (export "global_5" (global $shared-mutable-global))
;; PRIMARY-NEXT: (export "tag" (tag $shared-tag))
;; PRIMARY-NEXT: (export "keep" (func $keep))
;; PRIMARY-NEXT: (export "table_7" (table $3))
;; PRIMARY-NEXT: (export "table_8" (table $3))

;; SECONDARY: (import "primary" "memory" (memory $keep-memory2 1 1))
;; SECONDARY-NEXT: (import "primary" "memory_1" (memory $shared-memory 1 1))
;; SECONDARY-NEXT: (import "primary" "table" (table $keep-table2 1 1 (ref null $2)))
;; SECONDARY-NEXT: (import "primary" "table_3" (table $shared-table 1 1 funcref))
;; SECONDARY-NEXT: (import "primary" "table_7" (table $timport$2 1 funcref))
;; SECONDARY-NEXT: (import "primary" "global" (global $shared-global i32))
;; SECONDARY-NEXT: (import "primary" "table_8" (table $timport$2 1 funcref))
;; SECONDARY-NEXT: (import "primary" "global" (global $shared-immutable-global i32))
;; SECONDARY-NEXT: (import "primary" "global_5" (global $shared-mutable-global (mut i32)))
;; SECONDARY-NEXT: (import "primary" "keep" (func $keep (exact (param i32) (result i32))))
;; SECONDARY-NEXT: (import "primary" "tag" (tag $shared-tag (type $1) (param i32)))

;; SECONDARY: (global $split-global i32 (i32.const 20))
;; SECONDARY: (global $split-immutable-global i32 (i32.const 20))
;; SECONDARY-NEXT: (global $split-mutable-global (mut i32) (i32.const 20))
;; SECONDARY-NEXT: (memory $split-memory 1 1)
;; SECONDARY-NEXT: (data $split-data (memory $split-memory) (i32.const 0) "a")
;; SECONDARY-NEXT: (table $split-table 1 1 funcref)
Expand All @@ -109,9 +117,12 @@
(i32.const 0)
)
)
;; Uses $keep-global
;; Uses $keep-immutable-global and $keep-mutable-global
(drop
(global.get $keep-global)
(global.get $keep-immutable-global)
)
(drop
(global.get $keep-mutable-global)
)
;; Uses $keep-tag
(try_table (catch $keep-tag 0)
Expand All @@ -130,9 +141,12 @@
(i32.const 0)
)
)
;; Uses $shared-global
;; Uses $shared-immutable-global and $shared-mutable-global
(drop
(global.get $shared-immutable-global)
)
(drop
(global.get $shared-global)
(global.get $shared-mutable-global)
)
;; Uses $shared-tag
(try_table (catch $shared-tag 0)
Expand Down Expand Up @@ -166,9 +180,12 @@
(drop
(table.get $keep-table2 (i32.const 0))
)
;; Uses $split-global
;; Uses $split-immutable-global and $shared-mutable-global
(drop
(global.get $split-global)
(global.get $split-immutable-global)
)
(drop
(global.get $split-mutable-global)
)
;; Uses $split-tag
(try_table (catch $split-tag 0)
Expand All @@ -187,9 +204,12 @@
(i32.const 0)
)
)
;; Uses $shared-global
;; Uses $shared-immutable-global and $shared-mutable-global
(drop
(global.get $shared-immutable-global)
)
(drop
(global.get $shared-global)
(global.get $shared-mutable-global)
)
;; Uses $shared-tag
(try_table (catch $shared-tag 0)
Expand Down
52 changes: 0 additions & 52 deletions test/lit/wasm-split/transitive-globals-multi.wast

This file was deleted.

56 changes: 29 additions & 27 deletions test/lit/wasm-split/transitive-globals.wast
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,17 @@
(global $e i32 (global.get $f))
(global $d i32 (global.get $e))

;; PRIMARY: (global $f i32 (i32.const 42))
;; PRIMARY: (global $e i32 (global.get $f))

;; PRIMARY: (export "global" (global $e))

;; SECONDARY: (import "primary" "global" (global $e i32))

;; SECONDARY: (global $c i32 (i32.const 42))
;; SECONDARY: (global $b i32 (global.get $c))
;; SECONDARY: (global $a i32 (global.get $b))

;; SECONDARY: (global $d i32 (global.get $e))

;; This dead global is referring to a global ($a) that's moved to the
;; secondary module. This should be deleted.
;; PRIMARY-NOT: (global (global $dead i32 (global.get $a))
(global $dead i32 (global.get $a))

;; PRIMARY: (func $keep
;; PRIMARY-NEXT: (drop
;; PRIMARY-NEXT: (global.get $e)
;; PRIMARY-NEXT: )
;; PRIMARY-NEXT: )
(func $keep
(drop
(global.get $e)
)
)

;; Exclusively uses $a and $d, causing them to move to the secondary module
;; SECONDARY: (func $split
;; SECONDARY-NEXT: (drop
;; SECONDARY-NEXT: (global.get $a)
;; SECONDARY-NEXT: )
;; SECONDARY-NEXT: (drop
;; SECONDARY-NEXT: (global.get $d)
;; SECONDARY-NEXT: )
;; SECONDARY-NEXT: )
(func $split
(drop
(global.get $a)
Expand All @@ -66,3 +39,32 @@
)
)
)

;; PRIMARY: (module
;; PRIMARY-NEXT: (type $0 (func))
;; PRIMARY-NEXT: (global $f i32 (i32.const 42))
;; PRIMARY-NEXT: (global $e i32 (global.get $f))
;; PRIMARY-NEXT: (export "global" (global $e))
;; PRIMARY-NEXT: (func $keep
;; PRIMARY-NEXT: (drop
;; PRIMARY-NEXT: (global.get $e)
;; PRIMARY-NEXT: )
;; PRIMARY-NEXT: )
;; PRIMARY-NEXT: )

;; SECONDARY: (module
;; SECONDARY-NEXT: (type $0 (func))
;; SECONDARY-NEXT: (import "primary" "global" (global $e i32))
;; SECONDARY-NEXT: (global $c i32 (i32.const 42))
;; SECONDARY-NEXT: (global $b i32 (global.get $c))
;; SECONDARY-NEXT: (global $a i32 (global.get $b))
;; SECONDARY-NEXT: (global $d i32 (global.get $e))
;; SECONDARY-NEXT: (func $split
;; SECONDARY-NEXT: (drop
;; SECONDARY-NEXT: (global.get $a)
;; SECONDARY-NEXT: )
;; SECONDARY-NEXT: (drop
;; SECONDARY-NEXT: (global.get $d)
;; SECONDARY-NEXT: )
;; SECONDARY-NEXT: )
;; SECONDARY-NEXT: )
54 changes: 54 additions & 0 deletions test/lit/wasm-split/transitive-immutable-globals-multi.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
;; RUN: wasm-split -all -g --multi-split %s --manifest %S/transitive-globals-multi.wast.manifest --out-prefix=%t -o %t.wasm
;; RUN: wasm-dis -all %t.wasm | filecheck %s --check-prefix PRIMARY
;; RUN: wasm-dis -all %t1.wasm | filecheck %s --check-prefix SECONDARY1
;; RUN: wasm-dis -all %t2.wasm | filecheck %s --check-prefix SECONDARY2

;; Because global $e is used in both module1 ($split1) and module2 ($split2), $e
;; will be exported / imported, but we don't need to export $f.

(module
(global $f i32 (i32.const 42))
(global $e i32 (global.get $f))

(func $keep
(nop)
)

(func $split1
(drop (global.get $e))
)

(func $split2
(drop (global.get $e))
)
)

;; PRIMARY: (module
;; PRIMARY-NEXT: (type $0 (func))
;; PRIMARY-NEXT: (global $f i32 (i32.const 42))
;; PRIMARY-NEXT: (global $e i32 (global.get $f))
;; PRIMARY-NEXT: (export "global" (global $e))
;; PRIMARY-NEXT: (func $keep (type $0)
;; PRIMARY-NEXT: (nop)
;; PRIMARY-NEXT: )
;; PRIMARY-NEXT: )

;; SECONDARY1: (module
;; SECONDARY1-NEXT: (type $0 (func))
;; SECONDARY1-NEXT: (import "primary" "global" (global $e i32))
;; SECONDARY1-NEXT: (func $split1 (type $0)
;; SECONDARY1-NEXT: (drop
;; SECONDARY1-NEXT: (global.get $e)
;; SECONDARY1-NEXT: )
;; SECONDARY1-NEXT: )
;; SECONDARY1-NEXT: )

;; SECONDARY2: (module
;; SECONDARY2-NEXT: (type $0 (func))
;; SECONDARY2-NEXT: (import "primary" "global" (global $e i32))
;; SECONDARY2-NEXT: (func $split2 (type $0)
;; SECONDARY2-NEXT: (drop
;; SECONDARY2-NEXT: (global.get $e)
;; SECONDARY2-NEXT: )
;; SECONDARY2-NEXT: )
;; SECONDARY2-NEXT: )
Loading
Loading