summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/passes/Bysyncify.cpp166
-rw-r--r--test/passes/bysyncify.txt1336
-rw-r--r--test/passes/bysyncify_optimize-level=1.txt21
-rw-r--r--test/passes/bysyncify_pass-arg=bysyncify-ignore-imports.txt73
-rw-r--r--test/passes/bysyncify_pass-arg=bysyncify-ignore-indirect.txt298
-rw-r--r--test/passes/bysyncify_pass-arg=bysyncify-imports@env.import,env.import2.txt881
6 files changed, 1848 insertions, 927 deletions
diff --git a/src/passes/Bysyncify.cpp b/src/passes/Bysyncify.cpp
index 29b3cf242..e798be562 100644
--- a/src/passes/Bysyncify.cpp
+++ b/src/passes/Bysyncify.cpp
@@ -236,9 +236,54 @@ enum class DataOffset { BStackPos = 0, BStackEnd = 4 };
const auto STACK_ALIGN = 4;
+// A helper class for managing fake global names. Creates the globals and
+// provides mappings for using them.
+class GlobalHelper {
+ Module& module;
+
+public:
+ GlobalHelper(Module& module) : module(module) {
+ map[i32] = "bysyncify_fake_call_global_i32";
+ map[i64] = "bysyncify_fake_call_global_i64";
+ map[f32] = "bysyncify_fake_call_global_f32";
+ map[f64] = "bysyncify_fake_call_global_f64";
+ Builder builder(module);
+ for (auto& pair : map) {
+ auto type = pair.first;
+ auto name = pair.second;
+ rev[name] = type;
+ module.addGlobal(builder.makeGlobal(
+ name, type, LiteralUtils::makeZero(type, module), Builder::Mutable));
+ }
+ }
+
+ ~GlobalHelper() {
+ for (auto& pair : map) {
+ auto name = pair.second;
+ module.removeGlobal(name);
+ }
+ }
+
+ Name getName(Type type) { return map.at(type); }
+
+ Type getTypeOrNone(Name name) {
+ auto iter = rev.find(name);
+ if (iter != rev.end()) {
+ return iter->second;
+ }
+ return none;
+ }
+
+private:
+ std::map<Type, Name> map;
+ std::map<Name, Type> rev;
+};
+
// Analyze the entire module to see which calls may change the state, that
// is, start an unwind or rewind), either in itself or in something called
// by it.
+// Handles global module management, needed from the various parts of this
+// transformation.
class ModuleAnalyzer {
Module& module;
bool canIndirectChangeState;
@@ -268,7 +313,8 @@ public:
ModuleAnalyzer(Module& module,
std::function<bool(Name, Name)> canImportChangeState,
bool canIndirectChangeState)
- : module(module), canIndirectChangeState(canIndirectChangeState) {
+ : module(module), canIndirectChangeState(canIndirectChangeState),
+ globals(module) {
// Scan to see which functions can directly change the state.
// Also handle the bysyncify imports, removing them (as we will implement
// them later), and replace calls to them with calls to the later proper
@@ -429,6 +475,8 @@ public:
}
return walker.canChangeState;
}
+
+ GlobalHelper globals;
};
// Checks if something performs a call: either a direct or indirect call,
@@ -487,8 +535,9 @@ struct BysyncifyFlow : public Pass {
BysyncifyFlow(ModuleAnalyzer* analyzer) : analyzer(analyzer) {}
void
- runOnFunction(PassRunner* runner, Module* module_, Function* func) override {
+ runOnFunction(PassRunner* runner, Module* module_, Function* func_) override {
module = module_;
+ func = func_;
// If the function cannot change our state, we have nothing to do -
// we will never unwind or rewind the stack here.
if (!analyzer->needsInstrumentation(func)) {
@@ -518,6 +567,7 @@ private:
std::unique_ptr<BysyncifyBuilder> builder;
Module* module;
+ Function* func;
// Each call in the function has an index, noted during unwind and checked
// during rewind.
@@ -527,12 +577,15 @@ private:
if (!analyzer->canChangeState(curr)) {
return makeMaybeSkip(curr);
}
- // The IR is in flat form, which makes this much simpler. We basically
- // need to add skips to avoid code when rewinding, and checks around calls
- // with unwinding/rewinding support.
+ // The IR is in flat form, which makes this much simpler: there are no
+ // unnecessarily nested side effects or control flow, so we can add
+ // skips for rewinding in an easy manner, putting a single if around
+ // whole chunks of code. Also calls are separated out so that it is easy
+ // to add the necessary checks for them for unwinding/rewinding support.
//
// Aside from that, we must "linearize" all control flow so that we can
- // reach the right part when unwinding. For example, for an if we do this:
+ // reach the right part when rewinding, which is done by always skipping
+ // forward. For example, for an if we do this:
//
// if (condition()) {
// side1();
@@ -595,25 +648,28 @@ private:
// must be in one of the children.
assert(!analyzer->canChangeState(iff->condition));
// We must linearize this, which means we pass through both arms if we
- // are rewinding. This is pretty simple as in flat form the if condition
- // is either a const or a get, so easily copyable.
- // Start with the first arm, for which we reuse the original if.
- auto* otherArm = iff->ifFalse;
- iff->ifFalse = nullptr;
- auto* originalCondition = iff->condition;
+ // are rewinding.
+ if (!iff->ifFalse) {
+ iff->condition = builder->makeBinary(
+ OrInt32, iff->condition, builder->makeStateCheck(State::Rewinding));
+ iff->ifTrue = process(iff->ifTrue);
+ iff->finalize();
+ return iff;
+ }
+ auto conditionTemp = builder->addVar(func, i32);
+ iff->condition = builder->makeLocalTee(conditionTemp, iff->condition);
iff->condition = builder->makeBinary(
- OrInt32, originalCondition, builder->makeStateCheck(State::Rewinding));
+ OrInt32, iff->condition, builder->makeStateCheck(State::Rewinding));
iff->ifTrue = process(iff->ifTrue);
+ auto* otherArm = iff->ifFalse;
+ iff->ifFalse = nullptr;
iff->finalize();
- if (!otherArm) {
- return iff;
- }
// Add support for the second arm as well.
auto* otherIf = builder->makeIf(
builder->makeBinary(
OrInt32,
- builder->makeUnary(
- EqZInt32, ExpressionManipulator::copy(originalCondition, *module)),
+ builder->makeUnary(EqZInt32,
+ builder->makeLocalGet(conditionTemp, i32)),
builder->makeStateCheck(State::Rewinding)),
process(otherArm));
otherIf->finalize();
@@ -640,19 +696,39 @@ private:
// change the state
assert(doesCall(curr));
assert(curr->type == none);
+ // The case of a set is tricky: we must *not* execute the set when
+ // unwinding, since at that point we have a fake value for the return,
+ // and if we applied it to the local, it would end up saved and then
+ // potentially used later - and with coalescing, that may interfere
+ // with other things. Note also that at this point in the process we
+ // have not yet written the load saving/loading code, so the optimizer
+ // doesn't see that locals will have another use at the beginning and
+ // end of the function. We don't do that yet because we don't want it
+ // to force the final number of locals to be too high, but we also
+ // must be careful to never touch a local unnecessarily to avoid bugs.
+ // To implement this, write to a fake global; we'll fix it up after
+ // BysyncifyLocals locals adds local saving/restoring.
+ auto* set = curr->dynCast<LocalSet>();
+ if (set) {
+ auto name = analyzer->globals.getName(set->value->type);
+ curr = builder->makeGlobalSet(name, set->value);
+ set->value = builder->makeGlobalGet(name, set->value->type);
+ }
+ // Instrument the call itself (or, if a drop, the drop+call).
auto index = callIndex++;
// Execute the call, if either normal execution, or if rewinding and this
// is the right call to go into.
// TODO: we can read the next call index once in each function (but should
// avoid saving/restoring that local later)
- return builder->makeIf(
+ curr = builder->makeIf(
builder->makeIf(builder->makeStateCheck(State::Normal),
builder->makeConst(Literal(int32_t(1))),
makeCallIndexPeek(index)),
- builder->makeSequence(curr, makePossibleUnwind(index)));
+ builder->makeSequence(curr, makePossibleUnwind(index, set)));
+ return curr;
}
- Expression* makePossibleUnwind(Index index) {
+ Expression* makePossibleUnwind(Index index, Expression* ifNotUnwinding) {
// In this pass we emit an "unwind" as a call to a fake intrinsic. We
// will implement it in the later pass. (We can't create the unwind block
// target here, as the optimizer would remove it later; we can only add
@@ -660,7 +736,8 @@ private:
return builder->makeIf(
builder->makeStateCheck(State::Unwinding),
builder->makeCall(
- BYSYNCIFY_UNWIND, {builder->makeConst(Literal(int32_t(index)))}, none));
+ BYSYNCIFY_UNWIND, {builder->makeConst(Literal(int32_t(index)))}, none),
+ ifNotUnwinding);
}
Expression* makeCallIndexPeek(Index index) {
@@ -707,6 +784,29 @@ struct BysyncifyLocals : public WalkerPass<PostWalker<BysyncifyLocals>> {
}
}
+ void visitGlobalSet(GlobalSet* curr) {
+ auto type = analyzer->globals.getTypeOrNone(curr->name);
+ if (type != none) {
+ replaceCurrent(
+ builder->makeLocalSet(getFakeCallLocal(type), curr->value));
+ }
+ }
+
+ void visitGlobalGet(GlobalGet* curr) {
+ auto type = analyzer->globals.getTypeOrNone(curr->name);
+ if (type != none) {
+ replaceCurrent(builder->makeLocalGet(getFakeCallLocal(type), type));
+ }
+ }
+
+ Index getFakeCallLocal(Type type) {
+ auto iter = fakeCallLocals.find(type);
+ if (iter != fakeCallLocals.end()) {
+ return iter->second;
+ }
+ return fakeCallLocals[type] = builder->addVar(getFunction(), type);
+ }
+
void doWalkFunction(Function* func) {
// If the function cannot change our state, we have nothing to do -
// we will never unwind or rewind the stack here.
@@ -763,6 +863,7 @@ private:
Index rewindIndex;
Index numPreservableLocals;
+ std::map<Type, Index> fakeCallLocals;
Expression* makeLocalLoading() {
if (numPreservableLocals == 0) {
@@ -884,13 +985,22 @@ struct Bysyncify : public Pass {
PassRunner runner(module);
runner.add("flatten");
// Dce is useful here, since BysyncifyFlow makes control flow conditional,
- // which may make unreachable code look reachable. We also do some other
- // minimal optimization here in an unconditional way here, to counteract
- // the flattening.
+ // which may make unreachable code look reachable. It also lets us ignore
+ // unreachable code here.
runner.add("dce");
- runner.add("simplify-locals-nonesting");
- runner.add("merge-blocks");
- runner.add("vacuum");
+ if (optimize) {
+ // Optimizing before BsyncifyFlow is crucial, especially coalescing,
+ // because the flow changes add many branches, break up if-elses, etc.,
+ // all of which extend the live ranges of locals. In other words, it is
+ // not possible to coalesce well afterwards.
+ runner.add("simplify-locals-nonesting");
+ runner.add("reorder-locals");
+ runner.add("coalesce-locals");
+ runner.add("simplify-locals-nonesting");
+ runner.add("reorder-locals");
+ runner.add("merge-blocks");
+ runner.add("vacuum");
+ }
runner.add<BysyncifyFlow>(&analyzer);
runner.setIsNested(true);
runner.setValidateGlobally(false);
diff --git a/test/passes/bysyncify.txt b/test/passes/bysyncify.txt
index 814dd05d0..5c1c522a5 100644
--- a/test/passes/bysyncify.txt
+++ b/test/passes/bysyncify.txt
@@ -12,31 +12,44 @@
(func $do_sleep (; 0 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
- (local.set $0
- (global.get $sleeping)
- )
- (local.set $1
- (i32.eqz
- (local.get $0)
+ (block
+ (local.set $0
+ (global.get $sleeping)
)
- )
- (if
- (local.get $1)
- (block
- (global.set $sleeping
- (i32.const 1)
- )
- (call $bysyncify_start_unwind
- (i32.const 4)
+ (local.set $1
+ (i32.eqz
+ (local.get $0)
)
)
- (block
- (global.set $sleeping
- (i32.const 0)
+ (if
+ (local.get $1)
+ (block
+ (block $block
+ (global.set $sleeping
+ (i32.const 1)
+ )
+ (nop)
+ (call $bysyncify_start_unwind
+ (i32.const 4)
+ )
+ (nop)
+ )
+ (nop)
+ )
+ (block
+ (block $block0
+ (global.set $sleeping
+ (i32.const 0)
+ )
+ (nop)
+ (call $bysyncify_stop_rewind)
+ (nop)
+ )
+ (nop)
)
- (call $bysyncify_stop_rewind)
)
)
+ (nop)
)
(func $work (; 1 ;) (type $FUNCSIG$v)
(local $0 i32)
@@ -77,44 +90,63 @@
)
)
(block
- (if
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (call $stuff)
- )
- (if
- (if (result i32)
+ (block
+ (if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 0)
+ (block
+ (call $stuff)
+ (nop)
)
)
- (block
- (call $do_sleep)
- (if
+ (nop)
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 0)
)
)
+ (block
+ (call $do_sleep)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (block
+ (nop)
+ (call $stuff)
+ (nop)
+ )
+ )
+ (nop)
+ (nop)
)
(if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (call $stuff)
+ (nop)
)
)
)
@@ -182,29 +214,38 @@
)
)
)
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 0)
- )
- )
- (block
- (call $work)
- (if
+ (block
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 0)
)
)
+ (block
+ (call $work)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
)
)
)
@@ -232,16 +273,28 @@
(nop)
)
(func $second_event (; 4 ;) (type $FUNCSIG$v)
- (call $bysyncify_stop_unwind)
- (call $bysyncify_start_rewind
- (i32.const 4)
+ (block
+ (call $bysyncify_stop_unwind)
+ (nop)
+ (call $bysyncify_start_rewind
+ (i32.const 4)
+ )
+ (nop)
+ (call $work)
+ (nop)
)
- (call $work)
+ (nop)
)
(func $never_sleep (; 5 ;) (type $FUNCSIG$v)
- (call $stuff)
- (call $stuff)
- (call $stuff)
+ (block
+ (call $stuff)
+ (nop)
+ (call $stuff)
+ (nop)
+ (call $stuff)
+ (nop)
+ )
+ (nop)
)
(func $bysyncify_start_unwind (; 6 ;) (param $0 i32)
(if
@@ -345,29 +398,38 @@
)
)
)
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 0)
- )
- )
- (block
- (call $import)
- (if
+ (block
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 0)
)
)
+ (block
+ (call $import)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
)
)
)
@@ -404,6 +466,7 @@
(local $6 i32)
(local $7 i32)
(local $8 i32)
+ (local $9 i32)
(if
(i32.eq
(global.get $__bysyncify_state)
@@ -419,34 +482,34 @@
(i32.const -20)
)
)
- (local.set $7
+ (local.set $8
(i32.load
(global.get $__bysyncify_data)
)
)
(local.set $temp
(i32.load
- (local.get $7)
+ (local.get $8)
)
)
(local.set $1
(i32.load offset=4
- (local.get $7)
+ (local.get $8)
)
)
(local.set $2
(i32.load offset=8
- (local.get $7)
+ (local.get $8)
)
)
(local.set $3
(i32.load offset=12
- (local.get $7)
+ (local.get $8)
)
)
(local.set $4
(i32.load offset=16
- (local.get $7)
+ (local.get $8)
)
)
)
@@ -493,7 +556,7 @@
)
)
(block
- (local.set $2
+ (local.set $7
(call $import2)
)
(if
@@ -504,6 +567,9 @@
(br $__bysyncify_unwind
(i32.const 0)
)
+ (local.set $1
+ (local.get $7)
+ )
)
)
)
@@ -512,10 +578,22 @@
(global.get $__bysyncify_state)
(i32.const 0)
)
- (return
- (local.get $2)
+ (block
+ (local.set $temp
+ (local.get $1)
+ )
+ (nop)
+ (local.set $2
+ (local.get $temp)
+ )
+ (return
+ (local.get $2)
+ )
)
)
+ (nop)
+ (nop)
+ (nop)
)
(unreachable)
)
@@ -541,29 +619,29 @@
)
)
(block
- (local.set $8
+ (local.set $9
(i32.load
(global.get $__bysyncify_data)
)
)
(i32.store
- (local.get $8)
+ (local.get $9)
(local.get $temp)
)
(i32.store offset=4
- (local.get $8)
+ (local.get $9)
(local.get $1)
)
(i32.store offset=8
- (local.get $8)
+ (local.get $9)
(local.get $2)
)
(i32.store offset=12
- (local.get $8)
+ (local.get $9)
(local.get $3)
)
(i32.store offset=16
- (local.get $8)
+ (local.get $9)
(local.get $4)
)
(i32.store
@@ -584,6 +662,7 @@
(local $2 i32)
(local $3 i32)
(local $4 i32)
+ (local $5 i32)
(if
(i32.eq
(global.get $__bysyncify_state)
@@ -599,14 +678,14 @@
(i32.const -4)
)
)
- (local.set $3
+ (local.set $4
(i32.load
(global.get $__bysyncify_data)
)
)
(local.set $0
(i32.load
- (local.get $3)
+ (local.get $4)
)
)
)
@@ -639,32 +718,50 @@
)
)
)
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $2)
- (i32.const 0)
- )
- )
- (block
- (local.set $0
- (call $import2)
- )
- (if
+ (block
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $2)
(i32.const 0)
)
)
+ (block
+ (local.set $3
+ (call $import2)
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ (local.set $0
+ (local.get $3)
+ )
+ )
+ )
)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (block
+ (drop
+ (local.get $0)
+ )
+ (nop)
+ )
+ )
+ (nop)
)
)
(return)
@@ -689,13 +786,13 @@
)
)
(block
- (local.set $4
+ (local.set $5
(i32.load
(global.get $__bysyncify_data)
)
)
(i32.store
- (local.get $4)
+ (local.get $5)
(local.get $0)
)
(i32.store
@@ -716,6 +813,10 @@
(i32.const 17)
)
)
+ (drop
+ (local.get $0)
+ )
+ (nop)
)
(func $many-locals (; 7 ;) (type $FUNCSIG$ii) (param $x i32) (result i32)
(local $y i32)
@@ -837,24 +938,49 @@
(global.get $__bysyncify_state)
(i32.const 0)
)
- (loop $l
- (local.set $4
- (i32.add
- (local.get $y)
- (i32.const 1)
- )
- )
- (local.set $y
- (i32.div_s
- (local.get $4)
- (i32.const 3)
+ (block
+ (loop $l
+ (block
+ (local.set $2
+ (local.get $y)
+ )
+ (local.set $3
+ (i32.add
+ (local.get $2)
+ (i32.const 1)
+ )
+ )
+ (local.set $x
+ (local.get $3)
+ )
+ (nop)
+ (local.set $4
+ (local.get $x)
+ )
+ (local.set $5
+ (i32.div_s
+ (local.get $4)
+ (i32.const 3)
+ )
+ )
+ (local.set $y
+ (local.get $5)
+ )
+ (nop)
+ (local.set $6
+ (local.get $y)
+ )
+ (br_if $l
+ (local.get $6)
+ )
+ (nop)
)
+ (nop)
)
- (br_if $l
- (local.get $y)
- )
+ (nop)
)
)
+ (nop)
(if
(if (result i32)
(i32.eq
@@ -885,10 +1011,18 @@
(global.get $__bysyncify_state)
(i32.const 0)
)
- (return
- (local.get $y)
+ (block
+ (nop)
+ (local.set $7
+ (local.get $y)
+ )
+ (return
+ (local.get $7)
+ )
)
)
+ (nop)
+ (nop)
)
(unreachable)
)
@@ -1037,39 +1171,68 @@
)
)
)
- (if
- (i32.or
- (local.get $x)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 2)
- )
- )
- (if
- (if (result i32)
+ (block
+ (block
+ (if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (i32.const 1)
- (i32.eq
- (local.get $3)
- (i32.const 0)
+ (local.set $1
+ (local.get $x)
)
)
- (block
- (call $import)
- (if
+ (if
+ (i32.or
+ (local.get $1)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 2)
)
- (br $__bysyncify_unwind
- (i32.const 0)
+ )
+ (block
+ (if
+ (if (result i32)
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (i32.const 1)
+ (i32.eq
+ (local.get $3)
+ (i32.const 0)
+ )
+ )
+ (block
+ (call $import)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
)
)
)
)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
+ )
)
)
(return)
@@ -1124,6 +1287,7 @@
(local $3 i32)
(local $4 i32)
(local $5 i32)
+ (local $6 i32)
(if
(i32.eq
(global.get $__bysyncify_state)
@@ -1136,27 +1300,32 @@
(i32.load
(global.get $__bysyncify_data)
)
- (i32.const -8)
+ (i32.const -12)
)
)
- (local.set $4
+ (local.set $5
(i32.load
(global.get $__bysyncify_data)
)
)
(local.set $x
(i32.load
- (local.get $4)
+ (local.get $5)
)
)
(local.set $1
(i32.load offset=4
- (local.get $4)
+ (local.get $5)
+ )
+ )
+ (local.set $2
+ (i32.load offset=8
+ (local.get $5)
)
)
)
)
- (local.set $2
+ (local.set $3
(block $__bysyncify_unwind (result i32)
(block
(block
@@ -1175,7 +1344,7 @@
(i32.const -4)
)
)
- (local.set $3
+ (local.set $4
(i32.load
(i32.load
(global.get $__bysyncify_data)
@@ -1185,80 +1354,120 @@
)
)
(block
- (if
- (i32.or
- (local.get $x)
+ (block
+ (if
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 2)
+ (i32.const 0)
)
- )
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $3)
- (i32.const 0)
- )
+ (local.set $1
+ (local.get $x)
)
- (block
- (call $import3
- (i32.const 1)
- )
- (if
+ )
+ (block
+ (if
+ (i32.or
+ (local.tee $2
+ (local.get $1)
+ )
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
- )
- (br $__bysyncify_unwind
- (i32.const 0)
+ (i32.const 2)
)
)
- )
- )
- )
- (if
- (i32.or
- (i32.eqz
- (local.get $x)
- )
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 2)
- )
- )
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $3)
- (i32.const 1)
+ (block
+ (if
+ (if (result i32)
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (i32.const 1)
+ (i32.eq
+ (local.get $4)
+ (i32.const 0)
+ )
+ )
+ (block
+ (call $import3
+ (i32.const 1)
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
+ )
)
)
- (block
- (call $import3
- (i32.const 2)
- )
- (if
+ (if
+ (i32.or
+ (i32.eqz
+ (local.get $2)
+ )
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 2)
)
- (br $__bysyncify_unwind
- (i32.const 1)
+ )
+ (block
+ (if
+ (if (result i32)
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (i32.const 1)
+ (i32.eq
+ (local.get $4)
+ (i32.const 1)
+ )
+ )
+ (block
+ (call $import3
+ (i32.const 2)
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
)
)
)
)
)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
+ )
)
)
(return)
@@ -1270,7 +1479,7 @@
(i32.load
(global.get $__bysyncify_data)
)
- (local.get $2)
+ (local.get $3)
)
(i32.store
(global.get $__bysyncify_data)
@@ -1283,26 +1492,30 @@
)
)
(block
- (local.set $5
+ (local.set $6
(i32.load
(global.get $__bysyncify_data)
)
)
(i32.store
- (local.get $5)
+ (local.get $6)
(local.get $x)
)
(i32.store offset=4
- (local.get $5)
+ (local.get $6)
(local.get $1)
)
+ (i32.store offset=8
+ (local.get $6)
+ (local.get $2)
+ )
(i32.store
(global.get $__bysyncify_data)
(i32.add
(i32.load
(global.get $__bysyncify_data)
)
- (i32.const 8)
+ (i32.const 12)
)
)
)
@@ -1315,6 +1528,7 @@
(local $5 i32)
(local $6 i32)
(local $7 i32)
+ (local $8 i32)
(if
(i32.eq
(global.get $__bysyncify_state)
@@ -1327,37 +1541,42 @@
(i32.load
(global.get $__bysyncify_data)
)
- (i32.const -16)
+ (i32.const -20)
)
)
- (local.set $6
+ (local.set $7
(i32.load
(global.get $__bysyncify_data)
)
)
(local.set $x
(i32.load
- (local.get $6)
+ (local.get $7)
)
)
(local.set $1
(i32.load offset=4
- (local.get $6)
+ (local.get $7)
)
)
(local.set $2
(i32.load offset=8
- (local.get $6)
+ (local.get $7)
)
)
(local.set $3
(i32.load offset=12
- (local.get $6)
+ (local.get $7)
+ )
+ )
+ (local.set $4
+ (i32.load offset=16
+ (local.get $7)
)
)
)
)
- (local.set $4
+ (local.set $5
(block $__bysyncify_unwind (result i32)
(block
(block
@@ -1376,7 +1595,7 @@
(i32.const -4)
)
)
- (local.set $5
+ (local.set $6
(i32.load
(i32.load
(global.get $__bysyncify_data)
@@ -1388,57 +1607,79 @@
(block
(block
(if
- (i32.or
- (local.get $x)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 2)
- )
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
)
- (if
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (return
- (i32.const 1)
- )
+ (local.set $1
+ (local.get $x)
)
)
- (if
- (i32.or
- (i32.eqz
- (local.get $x)
- )
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 2)
- )
- )
+ (block
(if
- (if (result i32)
+ (i32.or
+ (local.tee $4
+ (local.get $1)
+ )
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 0)
+ (i32.const 2)
)
- (i32.const 1)
+ )
+ (if
(i32.eq
- (local.get $5)
+ (global.get $__bysyncify_state)
(i32.const 0)
)
+ (return
+ (i32.const 1)
+ )
)
- (block
- (call $import3
+ )
+ (if
+ (i32.or
+ (i32.eqz
+ (local.get $4)
+ )
+ (i32.eq
+ (global.get $__bysyncify_state)
(i32.const 2)
)
+ )
+ (block
(if
- (i32.eq
- (global.get $__bysyncify_state)
+ (if (result i32)
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
(i32.const 1)
+ (i32.eq
+ (local.get $6)
+ (i32.const 0)
+ )
)
- (br $__bysyncify_unwind
+ (block
+ (call $import3
+ (i32.const 2)
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
(i32.const 0)
)
+ (nop)
)
)
)
@@ -1449,10 +1690,14 @@
(global.get $__bysyncify_state)
(i32.const 0)
)
- (return
- (i32.const 3)
+ (block
+ (nop)
+ (return
+ (i32.const 3)
+ )
)
)
+ (nop)
)
(unreachable)
)
@@ -1465,7 +1710,7 @@
(i32.load
(global.get $__bysyncify_data)
)
- (local.get $4)
+ (local.get $5)
)
(i32.store
(global.get $__bysyncify_data)
@@ -1478,34 +1723,38 @@
)
)
(block
- (local.set $7
+ (local.set $8
(i32.load
(global.get $__bysyncify_data)
)
)
(i32.store
- (local.get $7)
+ (local.get $8)
(local.get $x)
)
(i32.store offset=4
- (local.get $7)
+ (local.get $8)
(local.get $1)
)
(i32.store offset=8
- (local.get $7)
+ (local.get $8)
(local.get $2)
)
(i32.store offset=12
- (local.get $7)
+ (local.get $8)
(local.get $3)
)
+ (i32.store offset=16
+ (local.get $8)
+ (local.get $4)
+ )
(i32.store
(global.get $__bysyncify_data)
(i32.add
(i32.load
(global.get $__bysyncify_data)
)
- (i32.const 16)
+ (i32.const 20)
)
)
)
@@ -1519,6 +1768,7 @@
(local $5 i32)
(local $6 i32)
(local $7 i32)
+ (local $8 i32)
(if
(i32.eq
(global.get $__bysyncify_state)
@@ -1531,37 +1781,42 @@
(i32.load
(global.get $__bysyncify_data)
)
- (i32.const -16)
+ (i32.const -20)
)
)
- (local.set $6
+ (local.set $7
(i32.load
(global.get $__bysyncify_data)
)
)
(local.set $x
(i32.load
- (local.get $6)
+ (local.get $7)
)
)
(local.set $1
(i32.load offset=4
- (local.get $6)
+ (local.get $7)
)
)
(local.set $2
(i32.load offset=8
- (local.get $6)
+ (local.get $7)
)
)
(local.set $3
(i32.load offset=12
- (local.get $6)
+ (local.get $7)
+ )
+ )
+ (local.set $4
+ (i32.load offset=16
+ (local.get $7)
)
)
)
)
- (local.set $4
+ (local.set $5
(block $__bysyncify_unwind (result i32)
(block
(block
@@ -1580,7 +1835,7 @@
(i32.const -4)
)
)
- (local.set $5
+ (local.set $6
(i32.load
(i32.load
(global.get $__bysyncify_data)
@@ -1592,58 +1847,80 @@
(block
(block
(if
- (i32.or
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (local.set $1
(local.get $x)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 2)
- )
)
+ )
+ (block
(if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
+ (i32.or
+ (local.tee $4
+ (local.get $1)
)
- (i32.const 1)
(i32.eq
- (local.get $5)
- (i32.const 0)
+ (global.get $__bysyncify_state)
+ (i32.const 2)
)
)
(block
- (call $import3
- (i32.const 1)
+ (if
+ (if (result i32)
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (i32.const 1)
+ (i32.eq
+ (local.get $6)
+ (i32.const 0)
+ )
+ )
+ (block
+ (call $import3
+ (i32.const 1)
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
)
(if
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
- )
- (br $__bysyncify_unwind
(i32.const 0)
)
+ (nop)
)
)
)
- )
- (if
- (i32.or
- (i32.eqz
- (local.get $x)
- )
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 2)
- )
- )
(if
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
+ (i32.or
+ (i32.eqz
+ (local.get $4)
+ )
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 2)
+ )
)
- (return
- (i32.const 2)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (return
+ (i32.const 2)
+ )
)
)
)
@@ -1653,10 +1930,14 @@
(global.get $__bysyncify_state)
(i32.const 0)
)
- (return
- (i32.const 3)
+ (block
+ (nop)
+ (return
+ (i32.const 3)
+ )
)
)
+ (nop)
)
(unreachable)
)
@@ -1669,7 +1950,7 @@
(i32.load
(global.get $__bysyncify_data)
)
- (local.get $4)
+ (local.get $5)
)
(i32.store
(global.get $__bysyncify_data)
@@ -1682,34 +1963,38 @@
)
)
(block
- (local.set $7
+ (local.set $8
(i32.load
(global.get $__bysyncify_data)
)
)
(i32.store
- (local.get $7)
+ (local.get $8)
(local.get $x)
)
(i32.store offset=4
- (local.get $7)
+ (local.get $8)
(local.get $1)
)
(i32.store offset=8
- (local.get $7)
+ (local.get $8)
(local.get $2)
)
(i32.store offset=12
- (local.get $7)
+ (local.get $8)
(local.get $3)
)
+ (i32.store offset=16
+ (local.get $8)
+ (local.get $4)
+ )
(i32.store
(global.get $__bysyncify_data)
(i32.add
(i32.load
(global.get $__bysyncify_data)
)
- (i32.const 16)
+ (i32.const 20)
)
)
)
@@ -1793,32 +2078,79 @@
)
)
)
- (loop $l
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $5)
- (i32.const 0)
- )
- )
+ (block
+ (loop $l
(block
- (call $import3
- (i32.const 1)
+ (if
+ (if (result i32)
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (i32.const 1)
+ (i32.eq
+ (local.get $5)
+ (i32.const 0)
+ )
+ )
+ (block
+ (call $import3
+ (i32.const 1)
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
)
(if
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
- )
- (br $__bysyncify_unwind
(i32.const 0)
)
+ (block
+ (nop)
+ (local.set $1
+ (local.get $x)
+ )
+ (local.set $2
+ (i32.add
+ (local.get $1)
+ (i32.const 1)
+ )
+ )
+ (local.set $x
+ (local.get $2)
+ )
+ (nop)
+ (local.set $3
+ (local.get $x)
+ )
+ (br_if $l
+ (local.get $3)
+ )
+ (nop)
+ )
)
+ (nop)
+ (nop)
+ (nop)
+ (nop)
+ (nop)
+ (nop)
+ (nop)
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
)
)
(if
@@ -1826,19 +2158,8 @@
(global.get $__bysyncify_state)
(i32.const 0)
)
- (block
- (local.set $x
- (i32.add
- (local.get $x)
- (i32.const 1)
- )
- )
- (br_if $l
- (local.get $x)
- )
- )
+ (nop)
)
- (nop)
)
)
(return)
@@ -1901,6 +2222,7 @@
(local $2 i32)
(local $3 i32)
(local $4 i32)
+ (local $5 i32)
(if
(i32.eq
(global.get $__bysyncify_state)
@@ -1916,14 +2238,14 @@
(i32.const -4)
)
)
- (local.set $3
+ (local.set $4
(i32.load
(global.get $__bysyncify_data)
)
)
(local.set $0
(i32.load
- (local.get $3)
+ (local.get $4)
)
)
)
@@ -1956,42 +2278,58 @@
)
)
)
- (loop $l
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $2)
- (i32.const 0)
- )
- )
- (block
- (local.set $0
- (call $import2)
- )
- (if
+ (block
+ (loop $l
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $2)
(i32.const 0)
)
)
+ (block
+ (local.set $3
+ (call $import2)
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ (local.set $0
+ (local.get $3)
+ )
+ )
+ )
)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (block
+ (br_if $l
+ (local.get $0)
+ )
+ (nop)
+ )
+ )
+ (nop)
)
(if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (br_if $l
- (local.get $0)
- )
+ (nop)
)
)
)
@@ -2017,13 +2355,13 @@
)
)
(block
- (local.set $4
+ (local.set $5
(i32.load
(global.get $__bysyncify_data)
)
)
(i32.store
- (local.get $4)
+ (local.get $5)
(local.get $0)
)
(i32.store
@@ -2076,69 +2414,95 @@
)
)
(block
- (if
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (call $boring)
- )
- (if
- (if (result i32)
+ (block
+ (if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 0)
+ (block
+ (call $boring)
+ (nop)
)
)
- (block
- (call $import)
- (if
+ (nop)
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 0)
)
)
+ (block
+ (call $import)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
)
- )
- (if
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (call $boring)
- )
- (if
- (if (result i32)
+ (if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 1)
+ (block
+ (nop)
+ (call $boring)
+ (nop)
)
)
- (block
- (call $import)
- (if
+ (nop)
+ (nop)
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 1)
)
)
+ (block
+ (call $import)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 1)
+ )
+ )
+ )
)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
)
)
)
@@ -2207,70 +2571,96 @@
)
)
(block
- (if
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (call $boring-deep)
- )
- (if
- (if (result i32)
+ (block
+ (if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 0)
+ (block
+ (call $boring-deep)
+ (nop)
)
)
- (block
- (call $import-deep)
- (if
+ (nop)
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 0)
)
)
+ (block
+ (call $import-deep)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
)
- )
- (if
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (call $boring)
- )
- (if
- (if (result i32)
+ (if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 1)
+ (block
+ (nop)
+ (call $boring)
+ (nop)
)
)
- (block
- (call $import)
- (if
+ (nop)
+ (nop)
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 1)
)
)
+ (block
+ (call $import)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
)
)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
+ )
)
)
(return)
@@ -2298,6 +2688,7 @@
)
(func $boring-deep (; 17 ;) (type $FUNCSIG$v)
(call $boring)
+ (nop)
)
(func $import-deep (; 18 ;) (type $FUNCSIG$v)
(local $0 i32)
@@ -2337,29 +2728,38 @@
)
)
)
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 0)
- )
- )
- (block
- (call $import)
- (if
+ (block
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 0)
)
)
+ (block
+ (call $import)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
)
)
)
diff --git a/test/passes/bysyncify_optimize-level=1.txt b/test/passes/bysyncify_optimize-level=1.txt
index 73456a7ae..89fb33ce4 100644
--- a/test/passes/bysyncify_optimize-level=1.txt
+++ b/test/passes/bysyncify_optimize-level=1.txt
@@ -139,7 +139,7 @@
(global.get $__bysyncify_state)
)
(block
- (local.set $0
+ (local.set $1
(call $import2)
)
(drop
@@ -151,6 +151,9 @@
)
)
)
+ (local.set $0
+ (local.get $1)
+ )
)
)
(if
@@ -585,11 +588,11 @@
)
(if
(i32.or
- (local.get $0)
(i32.eq
(global.get $__bysyncify_state)
(i32.const 2)
)
+ (local.get $0)
)
(if
(select
@@ -738,11 +741,11 @@
)
(if
(i32.or
- (local.get $0)
(i32.eq
(global.get $__bysyncify_state)
(i32.const 2)
)
+ (local.get $0)
)
(if
(i32.eqz
@@ -884,11 +887,11 @@
)
(if
(i32.or
- (local.get $0)
(i32.eq
(global.get $__bysyncify_state)
(i32.const 2)
)
+ (local.get $0)
)
(if
(select
@@ -1103,6 +1106,7 @@
(func $calls-loop2 (; 13 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
+ (local $2 i32)
(if
(i32.eq
(global.get $__bysyncify_state)
@@ -1144,7 +1148,7 @@
(i32.const -4)
)
)
- (local.set $1
+ (local.set $2
(i32.load
(i32.load
(global.get $__bysyncify_data)
@@ -1157,13 +1161,13 @@
(if
(select
(i32.eqz
- (local.get $1)
+ (local.get $2)
)
(i32.const 1)
(global.get $__bysyncify_state)
)
(block
- (local.set $0
+ (local.set $1
(call $import2)
)
(drop
@@ -1175,6 +1179,9 @@
)
)
)
+ (local.set $0
+ (local.get $1)
+ )
)
)
(if
diff --git a/test/passes/bysyncify_pass-arg=bysyncify-ignore-imports.txt b/test/passes/bysyncify_pass-arg=bysyncify-ignore-imports.txt
index adfaf6df7..515fa365a 100644
--- a/test/passes/bysyncify_pass-arg=bysyncify-ignore-imports.txt
+++ b/test/passes/bysyncify_pass-arg=bysyncify-ignore-imports.txt
@@ -16,24 +16,41 @@
(export "bysyncify_stop_rewind" (func $bysyncify_stop_rewind))
(func $calls-import (; 3 ;) (type $f)
(call $import)
+ (nop)
)
(func $calls-import2-drop (; 4 ;) (type $f)
(local $0 i32)
(local.set $0
(call $import2)
)
+ (drop
+ (local.get $0)
+ )
+ (nop)
)
(func $calls-import2-if-else (; 5 ;) (type $FUNCSIG$vi) (param $x i32)
(local $1 i32)
- (if
- (local.get $x)
- (call $import3
- (i32.const 1)
+ (block
+ (local.set $1
+ (local.get $x)
)
- (call $import3
- (i32.const 2)
+ (if
+ (local.get $1)
+ (block
+ (call $import3
+ (i32.const 1)
+ )
+ (nop)
+ )
+ (block
+ (call $import3
+ (i32.const 2)
+ )
+ (nop)
+ )
)
)
+ (nop)
)
(func $calls-indirect (; 6 ;) (type $FUNCSIG$vi) (param $x i32)
(local $1 i32)
@@ -101,31 +118,49 @@
)
)
)
- (if
- (if (result i32)
+ (block
+ (if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (i32.const 1)
- (i32.eq
- (local.get $3)
- (i32.const 0)
- )
- )
- (block
- (call_indirect (type $f)
+ (local.set $1
(local.get $x)
)
- (if
+ )
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $3)
(i32.const 0)
)
)
+ (block
+ (call_indirect (type $f)
+ (local.get $1)
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
)
)
)
diff --git a/test/passes/bysyncify_pass-arg=bysyncify-ignore-indirect.txt b/test/passes/bysyncify_pass-arg=bysyncify-ignore-indirect.txt
index 0534e827a..347ada93e 100644
--- a/test/passes/bysyncify_pass-arg=bysyncify-ignore-indirect.txt
+++ b/test/passes/bysyncify_pass-arg=bysyncify-ignore-indirect.txt
@@ -52,29 +52,38 @@
)
)
)
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 0)
- )
- )
- (block
- (call $import)
- (if
+ (block
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 0)
)
)
+ (block
+ (call $import)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
)
)
)
@@ -107,6 +116,7 @@
(local $2 i32)
(local $3 i32)
(local $4 i32)
+ (local $5 i32)
(if
(i32.eq
(global.get $__bysyncify_state)
@@ -122,14 +132,14 @@
(i32.const -4)
)
)
- (local.set $3
+ (local.set $4
(i32.load
(global.get $__bysyncify_data)
)
)
(local.set $0
(i32.load
- (local.get $3)
+ (local.get $4)
)
)
)
@@ -162,32 +172,50 @@
)
)
)
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $2)
- (i32.const 0)
- )
- )
- (block
- (local.set $0
- (call $import2)
- )
- (if
+ (block
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $2)
(i32.const 0)
)
)
+ (block
+ (local.set $3
+ (call $import2)
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ (local.set $0
+ (local.get $3)
+ )
+ )
+ )
)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (block
+ (drop
+ (local.get $0)
+ )
+ (nop)
+ )
+ )
+ (nop)
)
)
(return)
@@ -212,13 +240,13 @@
)
)
(block
- (local.set $4
+ (local.set $5
(i32.load
(global.get $__bysyncify_data)
)
)
(i32.store
- (local.get $4)
+ (local.get $5)
(local.get $0)
)
(i32.store
@@ -238,6 +266,7 @@
(local $3 i32)
(local $4 i32)
(local $5 i32)
+ (local $6 i32)
(if
(i32.eq
(global.get $__bysyncify_state)
@@ -250,27 +279,32 @@
(i32.load
(global.get $__bysyncify_data)
)
- (i32.const -8)
+ (i32.const -12)
)
)
- (local.set $4
+ (local.set $5
(i32.load
(global.get $__bysyncify_data)
)
)
(local.set $x
(i32.load
- (local.get $4)
+ (local.get $5)
)
)
(local.set $1
(i32.load offset=4
- (local.get $4)
+ (local.get $5)
+ )
+ )
+ (local.set $2
+ (i32.load offset=8
+ (local.get $5)
)
)
)
)
- (local.set $2
+ (local.set $3
(block $__bysyncify_unwind (result i32)
(block
(block
@@ -289,7 +323,7 @@
(i32.const -4)
)
)
- (local.set $3
+ (local.set $4
(i32.load
(i32.load
(global.get $__bysyncify_data)
@@ -299,80 +333,120 @@
)
)
(block
- (if
- (i32.or
- (local.get $x)
+ (block
+ (if
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 2)
+ (i32.const 0)
)
- )
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $3)
- (i32.const 0)
- )
+ (local.set $1
+ (local.get $x)
)
- (block
- (call $import3
- (i32.const 1)
- )
- (if
+ )
+ (block
+ (if
+ (i32.or
+ (local.tee $2
+ (local.get $1)
+ )
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
- )
- (br $__bysyncify_unwind
- (i32.const 0)
+ (i32.const 2)
)
)
- )
- )
- )
- (if
- (i32.or
- (i32.eqz
- (local.get $x)
- )
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 2)
- )
- )
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $3)
- (i32.const 1)
+ (block
+ (if
+ (if (result i32)
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (i32.const 1)
+ (i32.eq
+ (local.get $4)
+ (i32.const 0)
+ )
+ )
+ (block
+ (call $import3
+ (i32.const 1)
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
+ )
)
)
- (block
- (call $import3
- (i32.const 2)
- )
- (if
+ (if
+ (i32.or
+ (i32.eqz
+ (local.get $2)
+ )
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 2)
+ )
+ )
+ (block
+ (if
+ (if (result i32)
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (i32.const 1)
+ (i32.eq
+ (local.get $4)
+ (i32.const 1)
+ )
+ )
+ (block
+ (call $import3
+ (i32.const 2)
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 1)
+ )
+ )
+ )
)
- (br $__bysyncify_unwind
- (i32.const 1)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
)
)
)
)
)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
+ )
)
)
(return)
@@ -384,7 +458,7 @@
(i32.load
(global.get $__bysyncify_data)
)
- (local.get $2)
+ (local.get $3)
)
(i32.store
(global.get $__bysyncify_data)
@@ -397,35 +471,43 @@
)
)
(block
- (local.set $5
+ (local.set $6
(i32.load
(global.get $__bysyncify_data)
)
)
(i32.store
- (local.get $5)
+ (local.get $6)
(local.get $x)
)
(i32.store offset=4
- (local.get $5)
+ (local.get $6)
(local.get $1)
)
+ (i32.store offset=8
+ (local.get $6)
+ (local.get $2)
+ )
(i32.store
(global.get $__bysyncify_data)
(i32.add
(i32.load
(global.get $__bysyncify_data)
)
- (i32.const 8)
+ (i32.const 12)
)
)
)
)
(func $calls-indirect (; 6 ;) (type $FUNCSIG$vi) (param $x i32)
(local $1 i32)
- (call_indirect (type $f)
+ (local.set $1
(local.get $x)
)
+ (call_indirect (type $f)
+ (local.get $1)
+ )
+ (nop)
)
(func $bysyncify_start_unwind (; 7 ;) (param $0 i32)
(if
diff --git a/test/passes/bysyncify_pass-arg=bysyncify-imports@env.import,env.import2.txt b/test/passes/bysyncify_pass-arg=bysyncify-imports@env.import,env.import2.txt
index b75e59d88..b22e7d82a 100644
--- a/test/passes/bysyncify_pass-arg=bysyncify-imports@env.import,env.import2.txt
+++ b/test/passes/bysyncify_pass-arg=bysyncify-imports@env.import,env.import2.txt
@@ -12,31 +12,44 @@
(func $do_sleep (; 0 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
- (local.set $0
- (global.get $sleeping)
- )
- (local.set $1
- (i32.eqz
- (local.get $0)
+ (block
+ (local.set $0
+ (global.get $sleeping)
)
- )
- (if
- (local.get $1)
- (block
- (global.set $sleeping
- (i32.const 1)
- )
- (call $bysyncify_start_unwind
- (i32.const 4)
+ (local.set $1
+ (i32.eqz
+ (local.get $0)
)
)
- (block
- (global.set $sleeping
- (i32.const 0)
+ (if
+ (local.get $1)
+ (block
+ (block $block
+ (global.set $sleeping
+ (i32.const 1)
+ )
+ (nop)
+ (call $bysyncify_start_unwind
+ (i32.const 4)
+ )
+ (nop)
+ )
+ (nop)
+ )
+ (block
+ (block $block0
+ (global.set $sleeping
+ (i32.const 0)
+ )
+ (nop)
+ (call $bysyncify_stop_rewind)
+ (nop)
+ )
+ (nop)
)
- (call $bysyncify_stop_rewind)
)
)
+ (nop)
)
(func $work (; 1 ;) (type $FUNCSIG$v)
(local $0 i32)
@@ -77,44 +90,63 @@
)
)
(block
- (if
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (call $stuff)
- )
- (if
- (if (result i32)
+ (block
+ (if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 0)
+ (block
+ (call $stuff)
+ (nop)
)
)
- (block
- (call $do_sleep)
- (if
+ (nop)
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 0)
)
)
+ (block
+ (call $do_sleep)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (block
+ (nop)
+ (call $stuff)
+ (nop)
+ )
+ )
+ (nop)
+ (nop)
)
(if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (call $stuff)
+ (nop)
)
)
)
@@ -182,29 +214,38 @@
)
)
)
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 0)
- )
- )
- (block
- (call $work)
- (if
+ (block
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 0)
)
)
+ (block
+ (call $work)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
)
)
)
@@ -232,15 +273,26 @@
(nop)
)
(func $second_event (; 4 ;) (type $FUNCSIG$v)
- (call $bysyncify_start_rewind
- (i32.const 4)
+ (block
+ (call $bysyncify_start_rewind
+ (i32.const 4)
+ )
+ (nop)
+ (call $work)
+ (nop)
)
- (call $work)
+ (nop)
)
(func $never_sleep (; 5 ;) (type $FUNCSIG$v)
- (call $stuff)
- (call $stuff)
- (call $stuff)
+ (block
+ (call $stuff)
+ (nop)
+ (call $stuff)
+ (nop)
+ (call $stuff)
+ (nop)
+ )
+ (nop)
)
(func $bysyncify_start_unwind (; 6 ;) (param $0 i32)
(if
@@ -344,29 +396,38 @@
)
)
)
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 0)
- )
- )
- (block
- (call $import)
- (if
+ (block
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 0)
)
)
+ (block
+ (call $import)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
)
)
)
@@ -403,6 +464,7 @@
(local $6 i32)
(local $7 i32)
(local $8 i32)
+ (local $9 i32)
(if
(i32.eq
(global.get $__bysyncify_state)
@@ -418,34 +480,34 @@
(i32.const -20)
)
)
- (local.set $7
+ (local.set $8
(i32.load
(global.get $__bysyncify_data)
)
)
(local.set $temp
(i32.load
- (local.get $7)
+ (local.get $8)
)
)
(local.set $1
(i32.load offset=4
- (local.get $7)
+ (local.get $8)
)
)
(local.set $2
(i32.load offset=8
- (local.get $7)
+ (local.get $8)
)
)
(local.set $3
(i32.load offset=12
- (local.get $7)
+ (local.get $8)
)
)
(local.set $4
(i32.load offset=16
- (local.get $7)
+ (local.get $8)
)
)
)
@@ -492,7 +554,7 @@
)
)
(block
- (local.set $2
+ (local.set $7
(call $import2)
)
(if
@@ -503,6 +565,9 @@
(br $__bysyncify_unwind
(i32.const 0)
)
+ (local.set $1
+ (local.get $7)
+ )
)
)
)
@@ -511,10 +576,22 @@
(global.get $__bysyncify_state)
(i32.const 0)
)
- (return
- (local.get $2)
+ (block
+ (local.set $temp
+ (local.get $1)
+ )
+ (nop)
+ (local.set $2
+ (local.get $temp)
+ )
+ (return
+ (local.get $2)
+ )
)
)
+ (nop)
+ (nop)
+ (nop)
)
(unreachable)
)
@@ -540,29 +617,29 @@
)
)
(block
- (local.set $8
+ (local.set $9
(i32.load
(global.get $__bysyncify_data)
)
)
(i32.store
- (local.get $8)
+ (local.get $9)
(local.get $temp)
)
(i32.store offset=4
- (local.get $8)
+ (local.get $9)
(local.get $1)
)
(i32.store offset=8
- (local.get $8)
+ (local.get $9)
(local.get $2)
)
(i32.store offset=12
- (local.get $8)
+ (local.get $9)
(local.get $3)
)
(i32.store offset=16
- (local.get $8)
+ (local.get $9)
(local.get $4)
)
(i32.store
@@ -583,6 +660,7 @@
(local $2 i32)
(local $3 i32)
(local $4 i32)
+ (local $5 i32)
(if
(i32.eq
(global.get $__bysyncify_state)
@@ -598,14 +676,14 @@
(i32.const -4)
)
)
- (local.set $3
+ (local.set $4
(i32.load
(global.get $__bysyncify_data)
)
)
(local.set $0
(i32.load
- (local.get $3)
+ (local.get $4)
)
)
)
@@ -638,32 +716,50 @@
)
)
)
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $2)
- (i32.const 0)
- )
- )
- (block
- (local.set $0
- (call $import2)
- )
- (if
+ (block
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $2)
(i32.const 0)
)
)
+ (block
+ (local.set $3
+ (call $import2)
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ (local.set $0
+ (local.get $3)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (block
+ (drop
+ (local.get $0)
+ )
+ (nop)
+ )
)
+ (nop)
)
)
(return)
@@ -688,13 +784,13 @@
)
)
(block
- (local.set $4
+ (local.set $5
(i32.load
(global.get $__bysyncify_data)
)
)
(i32.store
- (local.get $4)
+ (local.get $5)
(local.get $0)
)
(i32.store
@@ -715,6 +811,10 @@
(i32.const 17)
)
)
+ (drop
+ (local.get $0)
+ )
+ (nop)
)
(func $many-locals (; 7 ;) (type $FUNCSIG$ii) (param $x i32) (result i32)
(local $y i32)
@@ -836,24 +936,49 @@
(global.get $__bysyncify_state)
(i32.const 0)
)
- (loop $l
- (local.set $4
- (i32.add
- (local.get $y)
- (i32.const 1)
- )
- )
- (local.set $y
- (i32.div_s
- (local.get $4)
- (i32.const 3)
+ (block
+ (loop $l
+ (block
+ (local.set $2
+ (local.get $y)
+ )
+ (local.set $3
+ (i32.add
+ (local.get $2)
+ (i32.const 1)
+ )
+ )
+ (local.set $x
+ (local.get $3)
+ )
+ (nop)
+ (local.set $4
+ (local.get $x)
+ )
+ (local.set $5
+ (i32.div_s
+ (local.get $4)
+ (i32.const 3)
+ )
+ )
+ (local.set $y
+ (local.get $5)
+ )
+ (nop)
+ (local.set $6
+ (local.get $y)
+ )
+ (br_if $l
+ (local.get $6)
+ )
+ (nop)
)
+ (nop)
)
- (br_if $l
- (local.get $y)
- )
+ (nop)
)
)
+ (nop)
(if
(if (result i32)
(i32.eq
@@ -884,10 +1009,18 @@
(global.get $__bysyncify_state)
(i32.const 0)
)
- (return
- (local.get $y)
+ (block
+ (nop)
+ (local.set $7
+ (local.get $y)
+ )
+ (return
+ (local.get $7)
+ )
)
)
+ (nop)
+ (nop)
)
(unreachable)
)
@@ -1036,39 +1169,68 @@
)
)
)
- (if
- (i32.or
- (local.get $x)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 2)
- )
- )
- (if
- (if (result i32)
+ (block
+ (block
+ (if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (i32.const 1)
- (i32.eq
- (local.get $3)
- (i32.const 0)
+ (local.set $1
+ (local.get $x)
)
)
- (block
- (call $import)
- (if
+ (if
+ (i32.or
+ (local.get $1)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 2)
)
- (br $__bysyncify_unwind
- (i32.const 0)
+ )
+ (block
+ (if
+ (if (result i32)
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (i32.const 1)
+ (i32.eq
+ (local.get $3)
+ (i32.const 0)
+ )
+ )
+ (block
+ (call $import)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
)
)
)
)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
+ )
)
)
(return)
@@ -1119,29 +1281,50 @@
)
(func $calls-import2-if-else (; 9 ;) (type $FUNCSIG$vi) (param $x i32)
(local $1 i32)
- (if
- (local.get $x)
- (call $import3
- (i32.const 1)
+ (block
+ (local.set $1
+ (local.get $x)
)
- (call $import3
- (i32.const 2)
+ (if
+ (local.get $1)
+ (block
+ (call $import3
+ (i32.const 1)
+ )
+ (nop)
+ )
+ (block
+ (call $import3
+ (i32.const 2)
+ )
+ (nop)
+ )
)
)
+ (nop)
)
(func $calls-import2-if-else-oneside (; 10 ;) (type $FUNCSIG$ii) (param $x i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
- (if
- (local.get $x)
- (return
- (i32.const 1)
+ (block
+ (local.set $1
+ (local.get $x)
)
- (call $import3
- (i32.const 2)
+ (if
+ (local.get $1)
+ (return
+ (i32.const 1)
+ )
+ (block
+ (call $import3
+ (i32.const 2)
+ )
+ (nop)
+ )
)
)
+ (nop)
(return
(i32.const 3)
)
@@ -1150,15 +1333,24 @@
(local $1 i32)
(local $2 i32)
(local $3 i32)
- (if
- (local.get $x)
- (call $import3
- (i32.const 1)
+ (block
+ (local.set $1
+ (local.get $x)
)
- (return
- (i32.const 2)
+ (if
+ (local.get $1)
+ (block
+ (call $import3
+ (i32.const 1)
+ )
+ (nop)
+ )
+ (return
+ (i32.const 2)
+ )
)
)
+ (nop)
(return
(i32.const 3)
)
@@ -1168,19 +1360,35 @@
(local $2 i32)
(local $3 i32)
(loop $l
- (call $import3
- (i32.const 1)
- )
- (local.set $x
- (i32.add
- (local.get $x)
+ (block
+ (call $import3
(i32.const 1)
)
+ (nop)
+ (local.set $1
+ (local.get $x)
+ )
+ (local.set $2
+ (i32.add
+ (local.get $1)
+ (i32.const 1)
+ )
+ )
+ (local.set $x
+ (local.get $2)
+ )
+ (nop)
+ (local.set $3
+ (local.get $x)
+ )
+ (br_if $l
+ (local.get $3)
+ )
+ (nop)
)
- (br_if $l
- (local.get $x)
- )
+ (nop)
)
+ (nop)
)
(func $calls-loop2 (; 13 ;) (type $FUNCSIG$v)
(local $0 i32)
@@ -1188,6 +1396,7 @@
(local $2 i32)
(local $3 i32)
(local $4 i32)
+ (local $5 i32)
(if
(i32.eq
(global.get $__bysyncify_state)
@@ -1203,14 +1412,14 @@
(i32.const -4)
)
)
- (local.set $3
+ (local.set $4
(i32.load
(global.get $__bysyncify_data)
)
)
(local.set $0
(i32.load
- (local.get $3)
+ (local.get $4)
)
)
)
@@ -1243,42 +1452,58 @@
)
)
)
- (loop $l
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $2)
- (i32.const 0)
- )
- )
- (block
- (local.set $0
- (call $import2)
- )
- (if
+ (block
+ (loop $l
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $2)
(i32.const 0)
)
)
+ (block
+ (local.set $3
+ (call $import2)
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ (local.set $0
+ (local.get $3)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (block
+ (br_if $l
+ (local.get $0)
+ )
+ (nop)
+ )
)
+ (nop)
)
(if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (br_if $l
- (local.get $0)
- )
+ (nop)
)
)
)
@@ -1304,13 +1529,13 @@
)
)
(block
- (local.set $4
+ (local.set $5
(i32.load
(global.get $__bysyncify_data)
)
)
(i32.store
- (local.get $4)
+ (local.get $5)
(local.get $0)
)
(i32.store
@@ -1363,69 +1588,95 @@
)
)
(block
- (if
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (call $boring)
- )
- (if
- (if (result i32)
+ (block
+ (if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 0)
+ (block
+ (call $boring)
+ (nop)
)
)
- (block
- (call $import)
- (if
+ (nop)
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 0)
)
)
+ (block
+ (call $import)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
)
- )
- (if
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (call $boring)
- )
- (if
- (if (result i32)
+ (if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 1)
+ (block
+ (nop)
+ (call $boring)
+ (nop)
)
)
- (block
- (call $import)
- (if
+ (nop)
+ (nop)
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 1)
)
)
+ (block
+ (call $import)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 1)
+ )
+ )
+ )
)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
)
)
)
@@ -1494,69 +1745,95 @@
)
)
(block
- (if
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (call $boring-deep)
- )
- (if
- (if (result i32)
+ (block
+ (if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 0)
+ (block
+ (call $boring-deep)
+ (nop)
)
)
- (block
- (call $import-deep)
- (if
+ (nop)
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 0)
)
)
+ (block
+ (call $import-deep)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
)
- )
- (if
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (call $boring)
- )
- (if
- (if (result i32)
+ (if
(i32.eq
(global.get $__bysyncify_state)
(i32.const 0)
)
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 1)
+ (block
+ (nop)
+ (call $boring)
+ (nop)
)
)
- (block
- (call $import)
- (if
+ (nop)
+ (nop)
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 1)
)
)
+ (block
+ (call $import)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
)
+ (nop)
)
)
)
@@ -1585,6 +1862,7 @@
)
(func $boring-deep (; 17 ;) (type $FUNCSIG$v)
(call $boring)
+ (nop)
)
(func $import-deep (; 18 ;) (type $FUNCSIG$v)
(local $0 i32)
@@ -1624,29 +1902,38 @@
)
)
)
- (if
- (if (result i32)
- (i32.eq
- (global.get $__bysyncify_state)
- (i32.const 0)
- )
- (i32.const 1)
- (i32.eq
- (local.get $1)
- (i32.const 0)
- )
- )
- (block
- (call $import)
- (if
+ (block
+ (if
+ (if (result i32)
(i32.eq
(global.get $__bysyncify_state)
- (i32.const 1)
+ (i32.const 0)
)
- (br $__bysyncify_unwind
+ (i32.const 1)
+ (i32.eq
+ (local.get $1)
(i32.const 0)
)
)
+ (block
+ (call $import)
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 1)
+ )
+ (br $__bysyncify_unwind
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (if
+ (i32.eq
+ (global.get $__bysyncify_state)
+ (i32.const 0)
+ )
+ (nop)
)
)
)