mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
Fix dead code eliminion bug on depend selector
Signed-off-by: yycc <yuyicen1@huawei.com> Change-Id: Ie431594e7f4876e5aa4cf35596adcf78a7cac652
This commit is contained in:
parent
97ef863363
commit
8ad76553a0
@ -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;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ group("ark_aot_js_test") {
|
||||
"undefined",
|
||||
"cjs",
|
||||
"for_await_of",
|
||||
"dead_code_elimination",
|
||||
]
|
||||
|
||||
deps = []
|
||||
|
18
test/aottest/dead_code_elimination/BUILD.gn
Normal file
18
test/aottest/dead_code_elimination/BUILD.gn
Normal 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 = []
|
||||
}
|
30
test/aottest/dead_code_elimination/dead_code_elimination.js
Normal file
30
test/aottest/dead_code_elimination/dead_code_elimination.js
Normal 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();
|
15
test/aottest/dead_code_elimination/expect_output.txt
Normal file
15
test/aottest/dead_code_elimination/expect_output.txt
Normal 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
|
Loading…
Reference in New Issue
Block a user