Commit 23b178b5 authored by Nico Hartmann's avatar Nico Hartmann Committed by V8 LUCI CQ

[turbofan] Enable --verify-simplified-lowering in debug

Bug: v8:12619
Change-Id: I3b9f82a21c9454ff37036e8abcf73862e38f1fc9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3494243Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Auto-Submit: Nico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Nico Hartmann <nicohartmann@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79338}
parent 35ddae0a
...@@ -41,7 +41,10 @@ void SimplifiedLoweringVerifier::CheckAndSet(Node* node, const Type& type, ...@@ -41,7 +41,10 @@ void SimplifiedLoweringVerifier::CheckAndSet(Node* node, const Type& type,
node_type_str.str().c_str()); node_type_str.str().c_str());
} }
} else { } else {
NodeProperties::SetType(node, type); // We store the type inferred by the verification pass. We do not update
// the node's type directly, because following phases might encounter
// unsound types as long as the verification is not complete.
SetType(node, type);
} }
SetTruncation(node, GeneralizeTruncation(trunc, type)); SetTruncation(node, GeneralizeTruncation(trunc, type));
} }
......
...@@ -16,6 +16,7 @@ class OperationTyper; ...@@ -16,6 +16,7 @@ class OperationTyper;
class SimplifiedLoweringVerifier final { class SimplifiedLoweringVerifier final {
public: public:
struct PerNodeData { struct PerNodeData {
Type type = Type::None();
Truncation truncation = Truncation::Any(IdentifyZeros::kDistinguishZeros); Truncation truncation = Truncation::Any(IdentifyZeros::kDistinguishZeros);
}; };
...@@ -38,6 +39,19 @@ class SimplifiedLoweringVerifier final { ...@@ -38,6 +39,19 @@ class SimplifiedLoweringVerifier final {
return type_guards_.find(node) != type_guards_.end(); return type_guards_.find(node) != type_guards_.end();
} }
void ResizeDataIfNecessary(Node* node) {
if (data_.size() <= node->id()) {
data_.resize(node->id() + 1);
}
DCHECK_EQ(data_[node->id()].truncation,
Truncation::Any(IdentifyZeros::kDistinguishZeros));
}
void SetType(Node* node, const Type& type) {
ResizeDataIfNecessary(node);
data_[node->id()].type = type;
}
Type InputType(Node* node, int input_index) const { Type InputType(Node* node, int input_index) const {
// TODO(nicohartmann): Check that inputs are typed, once all operators are // TODO(nicohartmann): Check that inputs are typed, once all operators are
// supported. // supported.
...@@ -45,15 +59,16 @@ class SimplifiedLoweringVerifier final { ...@@ -45,15 +59,16 @@ class SimplifiedLoweringVerifier final {
if (NodeProperties::IsTyped(input)) { if (NodeProperties::IsTyped(input)) {
return NodeProperties::GetType(input); return NodeProperties::GetType(input);
} }
// For nodes that have not been typed before SL, we use the type that has
// been inferred by the verifier.
if (input->id() < data_.size()) {
return data_[input->id()].type;
}
return Type::None(); return Type::None();
} }
void SetTruncation(Node* node, const Truncation& truncation) { void SetTruncation(Node* node, const Truncation& truncation) {
if (data_.size() <= node->id()) { ResizeDataIfNecessary(node);
data_.resize(node->id() + 1);
}
DCHECK_EQ(data_[node->id()].truncation,
Truncation::Any(IdentifyZeros::kDistinguishZeros));
data_[node->id()].truncation = truncation; data_[node->id()].truncation = truncation;
} }
......
...@@ -573,7 +573,8 @@ DEFINE_BOOL(assert_types, false, ...@@ -573,7 +573,8 @@ DEFINE_BOOL(assert_types, false,
// TODO(tebbi): Support allocating types from background thread. // TODO(tebbi): Support allocating types from background thread.
DEFINE_NEG_IMPLICATION(assert_types, concurrent_recompilation) DEFINE_NEG_IMPLICATION(assert_types, concurrent_recompilation)
DEFINE_BOOL(verify_simplified_lowering, false, // Enable verification of SimplifiedLowering in debug builds.
DEFINE_BOOL(verify_simplified_lowering, DEBUG_BOOL,
"verify graph generated by simplified lowering") "verify graph generated by simplified lowering")
DEFINE_BOOL(trace_compilation_dependencies, false, "trace code dependencies") DEFINE_BOOL(trace_compilation_dependencies, false, "trace code dependencies")
......
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