da1f06f239
If catch block is included into the loop, we should also include the whole try body as there are implicit control flow edges between each block in a try body and corresponding catch block. If try body is not included, analysis of loop invariant loads could miss conflicting stores and may conclude that certain loads are loop invariant although they are not. TEST=runtime/tests/vm/dart/regress_63336_test.dart Fixes https://github.com/dart-lang/sdk/issues/63336 Change-Id: I9d6b73e24554ee3bfbcc722fa59634ea90b00abb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501560 Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
67 lines
1.2 KiB
Dart
67 lines
1.2 KiB
Dart
// Copyright (c) 2025, 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.
|
|
|
|
void nested(int i) {
|
|
for (var i = 0; i < 10; ++i) {
|
|
while (i < 5) {
|
|
print(++i);
|
|
}
|
|
}
|
|
print(i);
|
|
while (i < 10) {
|
|
for (var j = 0; j < 3; ++j) {
|
|
i += j;
|
|
}
|
|
}
|
|
print(i);
|
|
}
|
|
|
|
void chainedHeaders(int i) {
|
|
do {
|
|
do {
|
|
i -= 17;
|
|
} while (i >= 0);
|
|
} while (i % 2 == 0);
|
|
}
|
|
|
|
void irreducible(int i) {
|
|
switch (i) {
|
|
L1:
|
|
case 1:
|
|
i += 1;
|
|
continue L2;
|
|
L2:
|
|
case 2:
|
|
i += 2;
|
|
if (i > 10) {
|
|
break;
|
|
}
|
|
continue L1;
|
|
}
|
|
}
|
|
|
|
int var63 = 28;
|
|
int var68 = 44;
|
|
|
|
void withTryBlock() {
|
|
var n = 43;
|
|
while (--n > 0) {
|
|
try {
|
|
var63++;
|
|
// Terminate block without reaching a loop backedge,
|
|
// so try body won't be included into the loop body
|
|
// through explicit predecessors of the backedge.
|
|
throw 'bye';
|
|
} on StackOverflowError {
|
|
rethrow;
|
|
} catch (_) {
|
|
// Load from 'var63' is considered loop invariant if
|
|
// loop body doesn't include try block body.
|
|
var68 = var63;
|
|
}
|
|
}
|
|
}
|
|
|
|
void main() {}
|