36 Star 56 Fork 391

OpenHarmony / arkcompiler_runtime_core

 / 详情

[Bug]: ets.stobj.name clobbers next field

已完成
创建于  
2024-05-07 00:52

发生了什么问题?

Compiler produces a store of 32-bit value to i8 and i16 fields in case of ets.stobj.name

期望行为是什么?

Compiler should produce a 8-bit/16-bit store

如何复现该缺陷

Failing test:

diff --git a/static_core/plugins/ets/compiler/optimizer/ir_builder/ets_inst_builder.cpp b/static_core/plugins/ets/compiler/optimizer/ir_builder/ets_inst_builder.cpp
index 0f519097..c97724b3 100644
--- a/static_core/plugins/ets/compiler/optimizer/ir_builder/ets_inst_builder.cpp
+++ b/static_core/plugins/ets/compiler/optimizer/ir_builder/ets_inst_builder.cpp
@@ -150,8 +150,13 @@ void InstBuilder::BuildStObjByName(const BytecodeInstruction *bcInst, DataType::
             break;
         case DataType::UINT8:
         case DataType::INT8:
+            id = RuntimeInterface::IntrinsicId::INTRINSIC_COMPILER_ETS_ST_OBJ_BY_NAME_I32;
+            type = DataType::INT8;
+            break;
         case DataType::UINT16:
         case DataType::INT16:
+            id = RuntimeInterface::IntrinsicId::INTRINSIC_COMPILER_ETS_ST_OBJ_BY_NAME_I32;
+            type = DataType::INT16;
         case DataType::UINT32:
         case DataType::INT32:
             id = RuntimeInterface::IntrinsicId::INTRINSIC_COMPILER_ETS_ST_OBJ_BY_NAME_I32;
diff --git a/static_core/plugins/ets/tests/lookup_by_name/CMakeLists.txt b/static_core/plugins/ets/tests/lookup_by_name/CMakeLists.txt
index 9ed04f73..d7035204 100644
--- a/static_core/plugins/ets/tests/lookup_by_name/CMakeLists.txt
+++ b/static_core/plugins/ets/tests/lookup_by_name/CMakeLists.txt
@@ -32,6 +32,7 @@ set(LOOKUP_BY_NAME_TEST_LIST
     "field_case_32bit"
     "field_case_64bit"
     "field_case_ref"
+    "peephole_8bit"
 )
 add_custom_target(ets_tests_lookup_by_name)
 add_dependencies(ets_tests ets_tests_lookup_by_name)
diff --git a/static_core/plugins/ets/tests/lookup_by_name/peephole_8bit.pa b/static_core/plugins/ets/tests/lookup_by_name/peephole_8bit.pa
new file mode 100644
index 00000000..3fe02a80
--- /dev/null
+++ b/static_core/plugins/ets/tests/lookup_by_name/peephole_8bit.pa
@@ -0,0 +1,29 @@
+.language eTS
+
+.record std.core.Object
+.record A {
+    i8 bar
+    i8 baz
+}
+
+.union_field i8 bar
+.union_field i8 baz
+
+.function i32 load__noinline__(A a0) {
+    ets.ldobj.name a0, baz
+    return
+}
+
+.function i32 main() {
+    newobj v0, A
+    ldai -1
+    ets.stobj.name v0, bar
+
+    call.short load__noinline__, v0
+    jnez error1
+    ldai 0
+    return
+error1:
+    ldai 1
+    return
+}

其他补充信息

版本或分支信息

  • master
  • Release 4.1
  • Release 4.0
  • Release 3.2

评论 (1)

Efremov Andrey 创建了任务
Efremov Andrey 添加了
 
bug
标签
展开全部操作日志

感谢提交Issue!关于Issue的交互操作,请访问OpenHarmony社区支持命令清单。如果有问题,请联系 @godmiaozi @peijiajun @Ishin Pavel @Vyacheslav Cherkashin 。如果需要调整订阅PR、Issue的变更状态,请访问链接

Thanks for submitting the issue. For more commands, please visit OpenHarmony Command List. If you have any questions, please refer to committer @godmiaozi @peijiajun @Ishin Pavel @Vyacheslav Cherkashin for help. If you need to change the subscription of a Pull Request or Issue, please visit the link.

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(2)
7387629 openharmony ci 1656582662
1
https://gitee.com/openharmony/arkcompiler_runtime_core.git
git@gitee.com:openharmony/arkcompiler_runtime_core.git
openharmony
arkcompiler_runtime_core
arkcompiler_runtime_core

搜索帮助

53164aa7 5694891 3bd8fe86 5694891