blob: a1bc8a6725b811e669dabe8a0a18d2875a83c5f5 [file] [edit]
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: wasm-ctor-eval %s --ctors=test --kept-exports=test --quiet -all -S -o - | filecheck %s
(module
;; CHECK: (type $0 (sub (struct (field i32) (field (mut (ref null $0))))))
(type $0 (sub (struct (field i32) (field (mut (ref null $0))))))
(import "__fuzz_import" "extern$" (global $gimport externref))
(global $global (ref null $0) (struct.new $0
(i32.const 0)
(struct.new_default $0)
))
(export "test" (func $0))
(func $0
(local $temp (ref null $0))
;; wasm-ctor-eval evals away the get of $global, since it sees all the data.
(local.set $temp
(global.get $global)
)
;; It stops at the read of the imported global, since that value depends on
;; runtime info.
;;
;; We should leave the module in a valid state: globals appear, and a start
;; function which applies one to the other. It should apply to the same global
;; that is then read from the remaining code in the export.
;;
;; Note that this get of the import vanishes in the final output, not because
;; we eval it, but because we run vacuum after.
(drop
(global.get $gimport)
)
(drop
(ref.as_non_null
(struct.get $0 1
(local.get $temp)
)
)
)
)
)
;; CHECK: (type $1 (func))
;; CHECK: (global $ctor-eval$global (ref (exact $0)) (struct.new $0
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (ref.null none)
;; CHECK-NEXT: ))
;; CHECK: (global $ctor-eval$global_3 (ref (exact $0)) (struct.new $0
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (ref.null none)
;; CHECK-NEXT: ))
;; CHECK: (export "test" (func $0_2))
;; CHECK: (start $start)
;; CHECK: (func $start (type $1)
;; CHECK-NEXT: (struct.set $0 1
;; CHECK-NEXT: (global.get $ctor-eval$global)
;; CHECK-NEXT: (global.get $ctor-eval$global_3)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK: (func $0_2 (type $1)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (ref.as_non_null
;; CHECK-NEXT: (struct.get $0 1
;; CHECK-NEXT: (global.get $ctor-eval$global)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )