blob: 2b38a836a625d6ec86dcc94f8ad0030e36cd5b1d [file] [edit]
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: foreach %s %t wasm-ctor-eval --ctors=test --kept-exports=test --quiet -all -S -o - | filecheck %s
;; We fail to eval away test (due to infinite recursion). As a result, we do
;; not update either global - not the one it modifies or even the one that the
;; start function modifies, and the start function remains as the start.
;; TODO: We could perhaps eval away the start in such cases, even when nothing
;; else gets optimized.
(module
;; CHECK: (type $0 (func))
;; CHECK: (type $1 (func (result i32)))
;; CHECK: (global $global1 (mut i32) (i32.const 0))
(global $global1 (mut i32) (i32.const 0))
;; CHECK: (global $global2 (mut i32) (i32.const 0))
(global $global2 (mut i32) (i32.const 0))
;; CHECK: (export "test" (func $test))
;; CHECK: (export "keepalive" (func $keepalive))
;; CHECK: (start $start)
(start $start)
;; CHECK: (func $start (type $0)
;; CHECK-NEXT: (global.set $global2
;; CHECK-NEXT: (i32.const 42)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $start
(global.set $global2
(i32.const 42)
)
)
;; CHECK: (func $test (type $0)
;; CHECK-NEXT: (call $test)
;; CHECK-NEXT: (global.set $global1
;; CHECK-NEXT: (i32.const 1337)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $test (export "test")
(call $test)
(global.set $global1
(i32.const 1337)
)
)
;; CHECK: (func $keepalive (type $1) (result i32)
;; CHECK-NEXT: (i32.add
;; CHECK-NEXT: (global.get $global1)
;; CHECK-NEXT: (global.get $global2)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $keepalive (export "keepalive") (result i32)
;; Keep the globals alive to show changes.
(i32.add
(global.get $global1)
(global.get $global2)
)
)
)