Fix dead code eliminion bug on depend selector

Signed-off-by: yycc <yuyicen1@huawei.com>
Change-Id: Ie431594e7f4876e5aa4cf35596adcf78a7cac652
This commit is contained in:
yycc 2023-11-04 16:23:06 +08:00
parent 97ef863363
commit 8ad76553a0
5 changed files with 65 additions and 3 deletions

View File

@ -60,9 +60,7 @@ GateRef DeadCodeElimination::EliminateDependSelector(GateRef gate)
for (size_t i = 0; i < dependCount; i++) {
auto depend = acc_.GetDep(gate, i);
if (acc_.IsDead(depend)) {
GateRef correspondingState = acc_.GetState(stateInput, i);
acc_.ReplaceDependIn(depend, i, deadGate_);
acc_.ReplaceStateIn(correspondingState, i, deadGate_);
acc_.ReplaceStateIn(stateInput, deadGate_, i);
visitor_->ReVisitGate(stateInput);
result = gate;
}

View File

@ -26,6 +26,7 @@ group("ark_aot_js_test") {
"undefined",
"cjs",
"for_await_of",
"dead_code_elimination",
]
deps = []

View File

@ -0,0 +1,18 @@
# 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.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_aot_js_test_action("dead_code_elimination") {
deps = []
}

View File

@ -0,0 +1,30 @@
/*
* 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.
*/
async function* foo() {
var i = 5;
while (i > 2) {
try {
yield 7;
print(i);
} catch (e) {
}
}
}
let a = foo();
a.next();
a.next();
a.next();

View File

@ -0,0 +1,15 @@
# Copyright (c) 2022 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.
5
5