[wasm-gc] Fix typing of phis

Phis should be typed correctly in the wasm typer even if the branch of
the first phi input is unreachable.

Bug: v8:7748
Change-Id: I9276127c0f92f9b74f61dd19502790c779ae3393
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4151198
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85204}
This commit is contained in:
Manos Koukoutos 2023-01-10 18:42:08 +01:00 committed by V8 LUCI CQ
parent 734795c1a0
commit 08eb7fec3d

View File

@ -126,14 +126,20 @@ Reduction WasmTyper::Reduce(Node* node) {
node->id(), computed_type.type.name().c_str());
break;
}
computed_type =
computed_type = {
wasm::kWasmBottom,
NodeProperties::GetType(NodeProperties::GetValueInput(node, 0))
.AsWasm();
for (int i = 1; i < node->op()->ValueInputCount(); i++) {
.AsWasm()
.module};
for (int i = 0; i < node->op()->ValueInputCount(); i++) {
Node* input = NodeProperties::GetValueInput(node, i);
TypeInModule input_type = NodeProperties::GetType(input).AsWasm();
// We do not want union of types from unreachable branches.
if (!input_type.type.is_bottom()) {
if (computed_type.type.is_bottom()) {
// We have not found a non-bottom branch yet.
computed_type = input_type;
} else if (!input_type.type.is_bottom()) {
// We do not want union of types from unreachable branches.
computed_type = wasm::Union(computed_type, input_type);
}
}