Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
42 changes: 42 additions & 0 deletions test/lit/passes/duplicate-import-elimination.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
;; RUN: foreach %s %t wasm-opt --duplicate-import-elimination -S -o - | filecheck %s

;; Merge imports with matching signatures and update calls, elements, and start.
;; The import with a different signature must remain distinct.

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

;; CHECK: (type $1 (func (param i32)))
;; CHECK-NOT: (import "env" "waka" (func $bar

;; CHECK: (import "env" "waka" (func $foo))
;; CHECK-NOT: (import "env" "waka" (func $bar
(import "env" "waka" (func $foo))
(import "env" "waka" (func $bar))
;; CHECK: (import "env" "waka" (func $wrong (param i32)))
;; CHECK-NOT: (import "env" "waka" (func $bar
(import "env" "waka" (func $wrong (param i32)))
(table 2 2 funcref)
(elem (i32.const 0) $foo $bar)
(start $bar)
;; CHECK: (table $0 2 2 funcref)

;; CHECK: (elem $0 (i32.const 0) $foo $foo)

;; CHECK: (export "baz" (func $baz))

;; CHECK: (start $foo)

;; CHECK: (func $baz
;; CHECK-NEXT: (call $foo)
;; CHECK-NEXT: (call $foo)
;; CHECK-NEXT: (call $wrong
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $baz (export "baz")
(call $foo)
(call $bar)
(call $wrong (i32.const 1))
)
)
57 changes: 57 additions & 0 deletions test/lit/passes/remove-unused-names_precompute.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: foreach %s %t wasm-opt --remove-unused-names --precompute -S -o - | filecheck %s

;; Preserve the interaction between name removal and a constant br_table target.

(module
;; CHECK: (type $0 (func (param i32)))

;; CHECK: (memory $0 256 256)
(memory $0 256 256)
;; CHECK: (func $__ZN10WasmAssertC2Ev__async_cb (param $$0 i32)
;; CHECK-NEXT: (block $switch-default
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: (block
;; CHECK-NEXT: (i32.store
;; CHECK-NEXT: (i32.const 12)
;; CHECK-NEXT: (i32.const 26)
;; CHECK-NEXT: )
;; CHECK-NEXT: (return)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (block
;; CHECK-NEXT: (local.set $$0
;; CHECK-NEXT: (i32.const 4)
;; CHECK-NEXT: )
;; CHECK-NEXT: (i32.store
;; CHECK-NEXT: (local.get $$0)
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $__ZN10WasmAssertC2Ev__async_cb (param $$0 i32)
(block $switch-default
(block $switch-case
(br_table $switch-case $switch-default
(i32.const 0)
)
)
(block
(i32.store
(i32.const 12)
(i32.const 26)
)
(return)
)
)
(block
(local.set $$0
(i32.const 4)
)
(i32.store
(local.get $$0)
(i32.const 1)
)
)
)
)
15 changes: 15 additions & 0 deletions test/lit/passes/set-globals.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: foreach %s %t wasm-opt --set-globals --pass-arg=set-globals@foo=1337,bar=42 -S -o - | filecheck %s

;; Set both an imported i32 global and a defined i64 global using pass arguments.

(module
;; an imported i32
(import "env" "in" (global $foo i32))

;; a defined i64
;; CHECK: (global $foo i32 (i32.const 1337))

;; CHECK: (global $bar i64 (i64.const 42))
(global $bar i64 (i64.const 1234))
)
17 changes: 0 additions & 17 deletions test/passes/duplicate-import-elimination.txt

This file was deleted.

13 changes: 0 additions & 13 deletions test/passes/duplicate-import-elimination.wast

This file was deleted.

25 changes: 0 additions & 25 deletions test/passes/remove-unused-names_precompute.txt

This file was deleted.

28 changes: 0 additions & 28 deletions test/passes/remove-unused-names_precompute.wast

This file was deleted.

1 change: 0 additions & 1 deletion test/passes/set-globals.passes

This file was deleted.

4 changes: 0 additions & 4 deletions test/passes/set-globals.txt

This file was deleted.

7 changes: 0 additions & 7 deletions test/passes/set-globals.wast

This file was deleted.

Loading