| ;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. |
| ;; RUN: foreach %s %t wasm-opt -all --dae2 -S -o - | filecheck %s --check-prefix=OPEN |
| ;; RUN: foreach %s %t wasm-opt -all --dae2 --closed-world -S -o - | filecheck %s --check-prefix=CLOSED |
| |
| (module |
| ;; OPEN: (func $target (type $0) (result i32) |
| ;; OPEN-NEXT: (i32.const 42) |
| ;; OPEN-NEXT: ) |
| ;; CLOSED: (func $target (type $0) (result i32) |
| ;; CLOSED-NEXT: (i32.const 42) |
| ;; CLOSED-NEXT: ) |
| (func $target (export "target") (result i32) |
| ;; The result is unused, but the function is exported, so we must keep it |
| ;; in both open and closed worlds. |
| (i32.const 42) |
| ) |
| ;; OPEN: (func $caller (type $1) |
| ;; OPEN-NEXT: (drop |
| ;; OPEN-NEXT: (call $target) |
| ;; OPEN-NEXT: ) |
| ;; OPEN-NEXT: ) |
| ;; CLOSED: (func $caller (type $1) |
| ;; CLOSED-NEXT: (drop |
| ;; CLOSED-NEXT: (call $target) |
| ;; CLOSED-NEXT: ) |
| ;; CLOSED-NEXT: ) |
| (func $caller (export "caller") |
| (drop (call $target)) |
| ) |
| ) |
| |
| (module |
| ;; OPEN: (import "env" "target" (func $target (type $0) (result i32))) |
| ;; CLOSED: (import "env" "target" (func $target (type $0) (result i32))) |
| (import "env" "target" (func $target (result i32))) |
| ;; OPEN: (func $caller (type $1) |
| ;; OPEN-NEXT: (drop |
| ;; OPEN-NEXT: (call $target) |
| ;; OPEN-NEXT: ) |
| ;; OPEN-NEXT: ) |
| ;; CLOSED: (func $caller (type $1) |
| ;; CLOSED-NEXT: (drop |
| ;; CLOSED-NEXT: (call $target) |
| ;; CLOSED-NEXT: ) |
| ;; CLOSED-NEXT: ) |
| (func $caller (export "caller") |
| ;; Same, but with an imported function. |
| (drop (call $target)) |
| ) |
| ) |
| |
| (module |
| ;; OPEN: (type $sig (func (result i32))) |
| ;; CLOSED: (type $sig (func)) |
| (type $sig (func (result i32))) |
| ;; OPEN: (func $target (type $sig) (result i32) |
| ;; OPEN-NEXT: (i32.const 42) |
| ;; OPEN-NEXT: ) |
| ;; CLOSED: (func $target (type $sig) |
| ;; CLOSED-NEXT: (drop |
| ;; CLOSED-NEXT: (i32.const 42) |
| ;; CLOSED-NEXT: ) |
| ;; CLOSED-NEXT: ) |
| (func $target (type $sig) (result i32) (i32.const 42)) |
| ;; OPEN: (func $caller (type $1) |
| ;; OPEN-NEXT: (drop |
| ;; OPEN-NEXT: (ref.func $target) |
| ;; OPEN-NEXT: ) |
| ;; OPEN-NEXT: ) |
| ;; CLOSED: (func $caller (type $0) |
| ;; CLOSED-NEXT: (drop |
| ;; CLOSED-NEXT: (ref.func $target) |
| ;; CLOSED-NEXT: ) |
| ;; CLOSED-NEXT: ) |
| (func $caller |
| ;; $target is referenced and $sig's result is unused. We can optimize in |
| ;; closed world but not open world. |
| (drop (ref.func $target)) |
| ) |
| ) |