diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cfg/Relooper.cpp | 3 | ||||
-rw-r--r-- | src/wasm-validator.h | 10 | ||||
-rw-r--r-- | src/wasm/wasm.cpp | 2 |
3 files changed, 14 insertions, 1 deletions
diff --git a/src/cfg/Relooper.cpp b/src/cfg/Relooper.cpp index f6250b888..b49114b74 100644 --- a/src/cfg/Relooper.cpp +++ b/src/cfg/Relooper.cpp @@ -251,6 +251,7 @@ wasm::Expression* Block::Render(RelooperBuilder& Builder, bool InLoop) { Root = Now; } else { CurrIf->ifFalse = Now; + CurrIf->finalize(); } } else { auto* Now = Builder.makeIf(Details->Condition, CurrContent); @@ -259,6 +260,7 @@ wasm::Expression* Block::Render(RelooperBuilder& Builder, bool InLoop) { Root = CurrIf = Now; } else { CurrIf->ifFalse = Now; + CurrIf->finalize(); CurrIf = Now; } } @@ -371,6 +373,7 @@ wasm::Expression* MultipleShape::Render(RelooperBuilder& Builder, bool InLoop) { FirstIf = CurrIf = Now; } else { CurrIf->ifFalse = Now; + CurrIf->finalize(); CurrIf = Now; } } diff --git a/src/wasm-validator.h b/src/wasm-validator.h index e9ce5911d..4d198ac34 100644 --- a/src/wasm-validator.h +++ b/src/wasm-validator.h @@ -161,6 +161,16 @@ public: if (curr->condition->type != unreachable) { shouldBeEqual(curr->type, none, curr, "if without else and reachable condition must be none"); } + } else { + if (curr->type != unreachable) { + shouldBeEqualOrFirstIsUnreachable(curr->ifTrue->type, curr->type, curr, "returning if-else's true must have right type"); + shouldBeEqualOrFirstIsUnreachable(curr->ifFalse->type, curr->type, curr, "returning if-else's false must have right type"); + } else { + if (curr->condition->type != unreachable) { + shouldBeEqual(curr->ifTrue->type, unreachable, curr, "unreachable if-else must have unreachable true"); + shouldBeEqual(curr->ifFalse->type, unreachable, curr, "unreachable if-else must have unreachable false"); + } + } } } diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index a11646e65..7e75d9178 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -210,7 +210,7 @@ void Block::finalize() { void If::finalize(WasmType type_) { type = type_; - if (type == none && (condition->type == unreachable || (ifFalse && ifTrue->type && ifFalse->type == unreachable))) { + if (type == none && (condition->type == unreachable || (ifFalse && ifTrue->type == unreachable && ifFalse->type == unreachable))) { type = unreachable; } } |