From 3b5293aea71355cffb853203b90a79e981875462 Mon Sep 17 00:00:00 2001 From: Manos Koukoutos Date: Fri, 21 May 2021 15:29:11 +0000 Subject: [PATCH] [turbofan] Impose uniqueness of parameters in verifier This is required by the register allocator. Bug: v8:11796 Change-Id: I714576fdd89487b88e5c412fe0d2981eb39210d8 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2756538 Reviewed-by: Georg Neis Commit-Queue: Manos Koukoutos Cr-Commit-Position: refs/heads/master@{#74725} --- src/compiler/verifier.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/compiler/verifier.cc b/src/compiler/verifier.cc index 8b7e22459b..bcb3413b47 100644 --- a/src/compiler/verifier.cc +++ b/src/compiler/verifier.cc @@ -251,13 +251,26 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) { } switch (node->opcode()) { - case IrOpcode::kStart: + case IrOpcode::kStart: { // Start has no inputs. CHECK_EQ(0, input_count); // Type is a tuple. // TODO(rossberg): Multiple outputs are currently typed as Internal. CheckTypeIs(node, Type::Internal()); + // Check that parameters are unique. We need this because the register + // allocator gets confused when there are two identical parameters which + // are both hard-assigned to the same register (such as the instance + // parameter in wasm). + std::unordered_set param_indices; + for (Node* use : node->uses()) { + if (all.IsLive(use) && use->opcode() == IrOpcode::kParameter) { + int index = ParameterIndexOf(use->op()); + CHECK_EQ(param_indices.count(index), 0); + param_indices.insert(index); + } + } break; + } case IrOpcode::kEnd: // End has no outputs. CHECK_EQ(0, node->op()->ValueOutputCount());