diff options
Diffstat (limited to 'src/ir/ReFinalize.cpp')
-rw-r--r-- | src/ir/ReFinalize.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/ir/ReFinalize.cpp b/src/ir/ReFinalize.cpp index a0166381b..947f9d975 100644 --- a/src/ir/ReFinalize.cpp +++ b/src/ir/ReFinalize.cpp @@ -44,16 +44,18 @@ void ReFinalize::visitBlock(Block* curr) { curr->type = Type::none; return; } - // Get the least upper bound type of the last element and all branch return - // values - curr->type = curr->list.back()->type; if (curr->name.is()) { - auto iter = breakValues.find(curr->name); - if (iter != breakValues.end()) { - curr->type = Type::getLeastUpperBound(curr->type, iter->second); + auto iter = breakTypes.find(curr->name); + if (iter != breakTypes.end()) { + // Set the type to be a supertype of the branch types and the flowed-out + // type. TODO: calculate proper LUBs to compute a new correct type in this + // situation. + iter->second.insert(curr->list.back()->type); + Type::ensureSuperType(iter->second, curr->type); return; } } + curr->type = curr->list.back()->type; if (curr->type == Type::unreachable) { return; } @@ -187,11 +189,7 @@ void ReFinalize::visitModule(Module* curr) { WASM_UNREACHABLE("unimp"); } void ReFinalize::updateBreakValueType(Name name, Type type) { if (type != Type::unreachable) { - if (breakValues.count(name) == 0) { - breakValues[name] = type; - } else { - breakValues[name] = Type::getLeastUpperBound(breakValues[name], type); - } + breakTypes[name].insert(type); } } |