diff --git a/compiler/optimizer/ir/basicblock.cpp b/compiler/optimizer/ir/basicblock.cpp index 88cdcacac60c8a525029bb3a14f98c3e9bdb84de..7031dabd739f4ecb7ecc45efe2aa0e432be46c39 100644 --- a/compiler/optimizer/ir/basicblock.cpp +++ b/compiler/optimizer/ir/basicblock.cpp @@ -295,7 +295,8 @@ void BasicBlock::JoinSuccessorBlock() if (loop->HasBackEdge(succ)) { loop->ReplaceBackEdge(succ, this); } - if (auto outer_loop = loop->GetOuterLoop()) { + for (auto outer_loop = loop->GetOuterLoop(); outer_loop != nullptr; + outer_loop = outer_loop->GetOuterLoop()) { if (outer_loop->HasBackEdge(succ)) { outer_loop->ReplaceBackEdge(succ, this); } diff --git a/plugins/ets/tests/checked/CMakeLists.txt b/plugins/ets/tests/checked/CMakeLists.txt index ac6f93e9be43a5930c11273d1a3a66c2b83a92cd..77956ffabaa33c4c77c08d940819323d79d359e7 100644 --- a/plugins/ets/tests/checked/CMakeLists.txt +++ b/plugins/ets/tests/checked/CMakeLists.txt @@ -163,6 +163,7 @@ if (PANDA_TARGET_AMD64 OR NOT PANDA_ARM64_TESTS_WITH_SANITIZER) panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_try_catch7.ets) panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_try_catch8.ets) panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_static_lookup.pa) + panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_nested_loops.ets) endif() panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/load_array.ets) diff --git a/plugins/ets/tests/checked/ets_nested_loops.ets b/plugins/ets/tests/checked/ets_nested_loops.ets new file mode 100644 index 0000000000000000000000000000000000000000..888f24c770c2844547f83ee8e5820ce04d3a7990 --- /dev/null +++ b/plugins/ets/tests/checked/ets_nested_loops.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +//! CHECKER IR Builder nested loops +//! RUN force_jit: true, options: "--compiler-regex='.*main.*'", entry: "ETSGLOBAL::main" + +//! CHECKER AOT IR Builder nested loops +//! SKIP_IF @architecture == "arm32" +//! RUN_PAOC options: "--compiler-regex='.*main.*'" +//! RUN entry: "ETSGLOBAL::main" + +class C0 { + x0: boolean + + f() : string { + return "" + } +} + +function main() : int { + let x2: C0 = {x0: true} + let fuel0 = 1 + while (fuel0 > 0) { + do { + fuel0-- + do { + fuel0-- + let s = x2.f() + } while (true && (fuel0 > 0)) + } while (true && (fuel0 > 0)) + } + return fuel0 + 1; +}