[vm/compiler] Relax flow graph checker for environment uses
Conditional constant propagation doesn't update environments and may also replace redefinition instructions with constants without updating environment uses of their original definitions. This causes discrepancy between arguments of a call and its environment. It is harmless and corresponding check in the flow graph checker can be relaxed. TEST=runtime/tests/vm/dart/regress_54128_test.dart Fixes https://github.com/dart-lang/sdk/issues/54128 Change-Id: I6e68e0525b7f110400435ac071934dd9a02eebd4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338941 Auto-Submit: Alexander Markov <alexmarkov@google.com> Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Slava Egorov <vegorov@google.com>
This commit is contained in:
committed by
Commit Queue
parent
1a12bf063a
commit
422b66a7e8
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// Regression test for https://github.com/dart-lang/sdk/issues/54128.
|
||||
// Verifies that flow graph checker doesn't crash in debug mode
|
||||
// after constant is propagated in the call argument but not its
|
||||
// enviornment.
|
||||
|
||||
@pragma('vm:never-inline')
|
||||
void foo(int port) {
|
||||
try {
|
||||
print('hi');
|
||||
} catch (e) {
|
||||
if (port != 0) rethrow;
|
||||
bar(port);
|
||||
}
|
||||
}
|
||||
|
||||
@pragma('vm:never-inline')
|
||||
void bar(int x) {
|
||||
print(x);
|
||||
}
|
||||
|
||||
void main() {
|
||||
foo(int.parse('2'));
|
||||
bar(int.parse('3'));
|
||||
}
|
||||
@@ -532,6 +532,12 @@ void FlowGraphChecker::AssertArgumentsInEnv(Definition* call) {
|
||||
// Redefinition instructions and boxing/unboxing are inserted
|
||||
// without updating environment uses (FlowGraph::RenameDominatedUses,
|
||||
// FlowGraph::InsertConversionsFor).
|
||||
//
|
||||
// Conditional constant propagation doesn't update environments either
|
||||
// and may also replace redefinition instructions with constants
|
||||
// without updating environment uses of their original definitions
|
||||
// (ConstantPropagator::InsertRedefinitionsAfterEqualityComparisons).
|
||||
//
|
||||
// Also, constants may belong to different blocks (e.g. function entry
|
||||
// and graph entry).
|
||||
Definition* arg_def =
|
||||
@@ -540,11 +546,8 @@ void FlowGraphChecker::AssertArgumentsInEnv(Definition* call) {
|
||||
env->ValueAt(env_base + i)
|
||||
->definition()
|
||||
->OriginalDefinitionIgnoreBoxingAndConstraints();
|
||||
ASSERT2((arg_def == env_def) ||
|
||||
(arg_def->IsConstant() && env_def->IsConstant() &&
|
||||
arg_def->AsConstant()->value().ptr() ==
|
||||
env_def->AsConstant()->value().ptr()),
|
||||
arg_def, env_def);
|
||||
ASSERT2((arg_def == env_def) || arg_def->IsConstant(), arg_def,
|
||||
env_def);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user