diff options
author | Alon Zakai <azakai@google.com> | 2019-06-30 08:43:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-30 08:43:06 -0700 |
commit | ba6cf2eff312a571fb1964e05aeb285c63a4772c (patch) | |
tree | c8c9e690f8866b2356b17f59a460b23569a87c44 /src | |
parent | 04c55fd025a972722cfdaf7ff30e8fc6e597e2af (diff) | |
download | binaryen-ba6cf2eff312a571fb1964e05aeb285c63a4772c.tar.gz binaryen-ba6cf2eff312a571fb1964e05aeb285c63a4772c.tar.bz2 binaryen-ba6cf2eff312a571fb1964e05aeb285c63a4772c.zip |
Bysyncify: fix skipping of flattened if condition (#2187)
We assigned it to a local, but didn't run maybeSkip on it. As a result, it was executed during rewinding, which broke restoring the saved value.
Found by the fuzzer.
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/Bysyncify.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/passes/Bysyncify.cpp b/src/passes/Bysyncify.cpp index 416869194..5e2f73e5c 100644 --- a/src/passes/Bysyncify.cpp +++ b/src/passes/Bysyncify.cpp @@ -658,7 +658,10 @@ private: return iff; } auto conditionTemp = builder->addVar(func, i32); - iff->condition = builder->makeLocalTee(conditionTemp, iff->condition); + // TODO: can avoid pre if the condition is a get or a const + auto* pre = + makeMaybeSkip(builder->makeLocalSet(conditionTemp, iff->condition)); + iff->condition = builder->makeLocalGet(conditionTemp, i32); iff->condition = builder->makeBinary( OrInt32, iff->condition, builder->makeStateCheck(State::Rewinding)); iff->ifTrue = process(iff->ifTrue); @@ -674,7 +677,7 @@ private: builder->makeStateCheck(State::Rewinding)), process(otherArm)); otherIf->finalize(); - return builder->makeSequence(iff, otherIf); + return builder->makeBlock({pre, iff, otherIf}); } else if (auto* loop = curr->dynCast<Loop>()) { loop->body = process(loop->body); return loop; |