Commit 391517ea authored by titzer's avatar titzer Committed by Commit bot

[wasm] Fix set_local appearing in unreachable code.

R=ahaas@chromium.org
LOG=Y
BUG=chromium:575861

Review URL: https://codereview.chromium.org/1573053003

Cr-Commit-Position: refs/heads/master@{#33213}
parent 2b352bb8
...@@ -903,7 +903,7 @@ class LR_WasmDecoder : public Decoder { ...@@ -903,7 +903,7 @@ class LR_WasmDecoder : public Decoder {
LocalType type = LocalOperand(p->pc(), &index, &unused); LocalType type = LocalOperand(p->pc(), &index, &unused);
Tree* val = p->last(); Tree* val = p->last();
if (type == val->type) { if (type == val->type) {
if (builder_) ssa_env_->locals[index] = val->node; if (build()) ssa_env_->locals[index] = val->node;
p->tree->node = val->node; p->tree->node = val->node;
} else { } else {
error(p->pc(), val->pc, "Typecheck failed in SetLocal"); error(p->pc(), val->pc, "Typecheck failed in SetLocal");
......
...@@ -1684,6 +1684,15 @@ TEST(Run_Wasm_Block_If_P_assign) { ...@@ -1684,6 +1684,15 @@ TEST(Run_Wasm_Block_If_P_assign) {
} }
TEST(Run_Wasm_DanglingAssign) {
WasmRunner<int32_t> r(MachineType::Int32());
// { return 0; p0 = 0; }
BUILD(r,
WASM_BLOCK(2, WASM_RETURN(WASM_I8(99)), WASM_SET_LOCAL(0, WASM_ZERO)));
CHECK_EQ(99, r.Call(1));
}
TEST(Run_Wasm_ExprIf_P) { TEST(Run_Wasm_ExprIf_P) {
WasmRunner<int32_t> r(MachineType::Int32()); WasmRunner<int32_t> r(MachineType::Int32());
// p0 ? 11 : 22; // p0 ? 11 : 22;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment