| ;; 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=t,s --kept-exports=t,s --quiet -all -S -o - | filecheck %s |
| |
| ;; A corner case where we export the start function and consider it a ctor. |
| ;; That it executes twice should not cause an internal error. |
| ;; |
| ;; The $counter shows how $s executes twice (each time adding 1), and $t once |
| ;; (adding 1000). |
| |
| (module |
| (rec |
| ;; CHECK: (rec |
| ;; CHECK-NEXT: (type $A (sub (shared (struct (field (mut (ref null $B))))))) |
| (type $A (sub (shared (struct (field (mut (ref null $B))))))) |
| ;; CHECK: (type $B (sub (shared (struct (field (mut (ref null (shared any)))))))) |
| (type $B (sub (shared (struct (field (mut (ref null (shared any)))))))) |
| ) |
| |
| (global $global (ref $A) (struct.new $A |
| (struct.new_default $B) |
| )) |
| |
| ;; CHECK: (type $2 (func)) |
| |
| ;; CHECK: (type $3 (func (result i32))) |
| |
| ;; CHECK: (global $ctor-eval$global_4 (ref (exact $A)) (struct.new $A |
| ;; CHECK-NEXT: (ref.null (shared none)) |
| ;; CHECK-NEXT: )) |
| |
| ;; CHECK: (global $ctor-eval$global_5 (ref (exact $B)) (struct.new $B |
| ;; CHECK-NEXT: (ref.null (shared none)) |
| ;; CHECK-NEXT: )) |
| |
| ;; CHECK: (global $counter (mut i32) (i32.const 1002)) |
| (global $counter (mut i32) (i32.const 0)) |
| |
| (export "s" (func $s)) |
| |
| (export "t" (func $t)) |
| |
| (start $s) |
| |
| (func $s |
| (global.set $counter |
| (i32.add |
| (global.get $counter) |
| (i32.const 1) |
| ) |
| ) |
| ) |
| |
| (func $t |
| (global.set $counter |
| (i32.add |
| (global.get $counter) |
| (i32.const 1000) |
| ) |
| ) |
| ) |
| |
| ;; CHECK: (export "keepalive" (func $keepalive)) |
| |
| ;; CHECK: (export "s" (func $s_5)) |
| |
| ;; CHECK: (export "t" (func $t_4)) |
| |
| ;; CHECK: (start $start) |
| |
| ;; CHECK: (func $keepalive (type $3) (result i32) |
| ;; CHECK-NEXT: (global.get $counter) |
| ;; CHECK-NEXT: ) |
| (func $keepalive (export "keepalive") (result i32) |
| ;; Keep the counter alive to show the result. |
| (global.get $counter) |
| ) |
| ) |
| |
| ;; CHECK: (func $start (type $2) |
| ;; CHECK-NEXT: (struct.set $A 0 |
| ;; CHECK-NEXT: (global.get $ctor-eval$global_4) |
| ;; CHECK-NEXT: (global.get $ctor-eval$global_5) |
| ;; CHECK-NEXT: ) |
| ;; CHECK-NEXT: ) |
| |
| ;; CHECK: (func $t_4 (type $2) |
| ;; CHECK-NEXT: (nop) |
| ;; CHECK-NEXT: ) |
| |
| ;; CHECK: (func $s_5 (type $2) |
| ;; CHECK-NEXT: (nop) |
| ;; CHECK-NEXT: ) |