;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. ;; NOTE: This test was ported using port_passes_tests_to_lit.py and could be cleaned up. ;; RUN: foreach %s %t wasm-opt --asyncify --optimize-level=1 -S -o - | filecheck %s (module ;; CHECK: (type $0 (func)) ;; CHECK: (type $1 (func (param i32))) ;; CHECK: (type $2 (func (result i32))) ;; CHECK: (type $3 (func (param i32) (result i32))) ;; CHECK: (import "env" "import" (func $import)) (import "env" "import" (func $import)) ;; CHECK: (import "env" "import2" (func $import2 (result i32))) (import "env" "import2" (func $import2 (result i32))) ;; CHECK: (import "env" "import3" (func $import3 (param i32))) (import "env" "import3" (func $import3 (param i32))) (memory 1 2) ;; CHECK: (global $__asyncify_state (mut i32) (i32.const 0)) ;; CHECK: (global $__asyncify_data (mut i32) (i32.const 0)) ;; CHECK: (memory $0 1 2) ;; CHECK: (export "asyncify_start_unwind" (func $asyncify_start_unwind)) ;; CHECK: (export "asyncify_stop_unwind" (func $asyncify_stop_unwind)) ;; CHECK: (export "asyncify_start_rewind" (func $asyncify_start_rewind)) ;; CHECK: (export "asyncify_stop_rewind" (func $asyncify_stop_rewind)) ;; CHECK: (export "asyncify_get_state" (func $asyncify_get_state)) ;; CHECK: (func $calls-import ;; CHECK-NEXT: (local $0 i32) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (block $__asyncify_unwind (result i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (if (result i32) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (else ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $import) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $__asyncify_unwind ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (return) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $calls-import (call $import) ) ;; CHECK: (func $calls-import2 (result i32) ;; CHECK-NEXT: (local $0 i32) ;; CHECK-NEXT: (local $1 i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $1 ;; CHECK-NEXT: (block $__asyncify_unwind (result i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (if (result i32) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (else ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (local.set $1 ;; CHECK-NEXT: (call $import2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $__asyncify_unwind ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (return ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) (func $calls-import2 (result i32) (local $temp i32) (local.set $temp (call $import2)) (return (local.get $temp)) ) ;; CHECK: (func $calls-import2-drop ;; CHECK-NEXT: (local $0 i32) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (block $__asyncify_unwind (result i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (if (result i32) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (else ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (call $import2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $__asyncify_unwind ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (return) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $calls-import2-drop (drop (call $import2)) ) ;; CHECK: (func $calls-nothing ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (i32.const 17) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $calls-nothing (drop (i32.eqz (i32.const 17))) ) ;; CHECK: (func $many-locals (param $0 i32) (result i32) ;; CHECK-NEXT: (local $1 i32) ;; CHECK-NEXT: (local $2 i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $1 ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (block $__asyncify_unwind (result i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $2 ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (loop $l ;; CHECK-NEXT: (br_if $l ;; CHECK-NEXT: (local.tee $1 ;; CHECK-NEXT: (i32.div_s ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 3) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (local.get $2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $import) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $__asyncify_unwind ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (return ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) (func $many-locals (param $x i32) (result i32) (local $y i32) (loop $l (local.set $x (i32.add (local.get $y) (i32.const 1)) ) (local.set $y (i32.div_s (local.get $x) (i32.const 3)) ) (br_if $l (local.get $y)) ) (call $import) (return (local.get $y)) ) ;; CHECK: (func $calls-import2-if (param $0 i32) ;; CHECK-NEXT: (local $1 i32) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (block $__asyncify_unwind (result i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (select ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (if (result i32) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (else ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $import) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $__asyncify_unwind ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (return) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $calls-import2-if (param $x i32) (if (local.get $x) (then (call $import) ) ) ) ;; CHECK: (func $calls-import2-if-else (param $0 i32) ;; CHECK-NEXT: (local $1 i32) ;; CHECK-NEXT: (local $2 i32) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (block $__asyncify_unwind (result i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (select ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (local.tee $1 ;; CHECK-NEXT: (select ;; CHECK-NEXT: (if (result i32) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (else ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (block (result i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $2 ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (local.get $2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $import3 ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $__asyncify_unwind ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (local.get $2) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $import3 ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $__asyncify_unwind ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (return) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $calls-import2-if-else (param $x i32) (if (local.get $x) (then (call $import3 (i32.const 1)) ) (else (call $import3 (i32.const 2)) ) ) ) ;; CHECK: (func $calls-import2-if-else-oneside (param $0 i32) (result i32) ;; CHECK-NEXT: (local $1 i32) ;; CHECK-NEXT: (local $2 i32) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (block $__asyncify_unwind (result i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $1 ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (select ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (local.tee $2 ;; CHECK-NEXT: (select ;; CHECK-NEXT: (local.get $2) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (return ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.and ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (local.get $2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $import3 ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $__asyncify_unwind ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (return ;; CHECK-NEXT: (i32.const 3) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) (func $calls-import2-if-else-oneside (param $x i32) (result i32) (if (local.get $x) (then (return (i32.const 1)) ) (else (call $import3 (i32.const 2)) ) ) (return (i32.const 3)) ) ;; CHECK: (func $calls-import2-if-else-oneside2 (param $0 i32) (result i32) ;; CHECK-NEXT: (local $1 i32) ;; CHECK-NEXT: (local $2 i32) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (block $__asyncify_unwind (result i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (select ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (local.tee $1 ;; CHECK-NEXT: (select ;; CHECK-NEXT: (if (result i32) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (else ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (if (result i32) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (else ;; CHECK-NEXT: (local.get $2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $import3 ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $__asyncify_unwind ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.and ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (return ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (return ;; CHECK-NEXT: (i32.const 3) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) (func $calls-import2-if-else-oneside2 (param $x i32) (result i32) (if (local.get $x) (then (call $import3 (i32.const 1)) ) (else (return (i32.const 2)) ) ) (return (i32.const 3)) ) ;; CHECK: (func $calls-loop (param $0 i32) ;; CHECK-NEXT: (local $1 i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $1 ;; CHECK-NEXT: (block $__asyncify_unwind (result i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $1 ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (loop $l ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $import3 ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $__asyncify_unwind ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (br_if $l ;; CHECK-NEXT: (local.tee $0 ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (return) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $calls-loop (param $x i32) (loop $l (call $import3 (i32.const 1)) (local.set $x (i32.add (local.get $x) (i32.const 1)) ) (br_if $l (local.get $x) ) ) ) ;; CHECK: (func $calls-loop2 ;; CHECK-NEXT: (local $0 i32) ;; CHECK-NEXT: (local $1 i32) ;; CHECK-NEXT: (local $2 i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $1 ;; CHECK-NEXT: (block $__asyncify_unwind (result i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $2 ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (loop $l ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (local.get $2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (local.set $1 ;; CHECK-NEXT: (call $import2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $__asyncify_unwind ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (br_if $l ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (select ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (return) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $calls-loop2 (loop $l (br_if $l (call $import2) ) ) ) ;; CHECK: (func $calls-mix ;; CHECK-NEXT: (local $0 i32) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (block $__asyncify_unwind (result i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $boring) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $import) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $__asyncify_unwind ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $boring) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $import) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $__asyncify_unwind ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (return) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $calls-mix (call $boring) (call $import) (call $boring) (call $import) ) ;; CHECK: (func $boring ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) (func $boring) ;; CHECK: (func $calls-mix-deep ;; CHECK-NEXT: (local $0 i32) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (block $__asyncify_unwind (result i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $boring-deep) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $import-deep) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $__asyncify_unwind ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $boring) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $import) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $__asyncify_unwind ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (return) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $calls-mix-deep (call $boring-deep) (call $import-deep) (call $boring) (call $import) ) ;; CHECK: (func $boring-deep ;; CHECK-NEXT: (call $boring) ;; CHECK-NEXT: ) (func $boring-deep (call $boring) ) ;; CHECK: (func $import-deep ;; CHECK-NEXT: (local $0 i32) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (block $__asyncify_unwind (result i32) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.or ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (if (result i32) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.sub ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (else ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $import) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $__asyncify_unwind ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.eq ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (return) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.store ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $import-deep (call $import) ) ) ;; CHECK: (func $asyncify_start_unwind (param $0 i32) ;; CHECK-NEXT: (global.set $__asyncify_state ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (global.set $__asyncify_data ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.gt_u ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.load offset=4 ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK: (func $asyncify_stop_unwind ;; CHECK-NEXT: (global.set $__asyncify_state ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.gt_u ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.load offset=4 ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK: (func $asyncify_start_rewind (param $0 i32) ;; CHECK-NEXT: (global.set $__asyncify_state ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (global.set $__asyncify_data ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.gt_u ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.load offset=4 ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK: (func $asyncify_stop_rewind ;; CHECK-NEXT: (global.set $__asyncify_state ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.gt_u ;; CHECK-NEXT: (i32.load ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.load offset=4 ;; CHECK-NEXT: (global.get $__asyncify_data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK: (func $asyncify_get_state (result i32) ;; CHECK-NEXT: (global.get $__asyncify_state) ;; CHECK-NEXT: )