array memset testing
还没有人认领这个 Issue。
- 主要语言
- Rust
- 星标
- 3.4k
- 派生
- 126
- PR 合并指标
- 30 天内没有已合并 PR
描述
UPDATED: I tried a few mutations in PR which do not trigger any CI failures on my personal fork: https://github.com/brody2consult/rust-gpu/pull/2
diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs
index d86db1cbd0..c2143f4436 100644
--- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs
+++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs
@@ -290,22 +290,15 @@ macro_rules! simple_uni_op {
}
fn memset_fill_u16(b: u8) -> u16 {
- b as u16 | ((b as u16) << 8)
+ 0xbad_u16 | ((b as u16) << 10)
}
fn memset_fill_u32(b: u8) -> u32 {
- b as u32 | ((b as u32) << 8) | ((b as u32) << 16) | ((b as u32) << 24)
+ 0xbad_u32 | ((b as u32) << 20)
}
fn memset_fill_u64(b: u8) -> u64 {
- b as u64
- | ((b as u64) << 8)
- | ((b as u64) << 16)
- | ((b as u64) << 24)
- | ((b as u64) << 32)
- | ((b as u64) << 40)
- | ((b as u64) << 48)
- | ((b as u64) << 56)
+ 0xbad_u64 | ((b as u64) << 30)
}
fn memset_dynamic_scalar(
@@ -384,9 +377,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
32 => self
.constant_u32(self.span(), memset_fill_u32(fill_byte))
.def(self),
- 64 => self
- .constant_u64(self.span(), memset_fill_u64(fill_byte))
- .def(self),
_ => self.fatal(format!(
"memset on integer width {width} not implemented yet"
)),
@@ -2911,7 +2901,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
};
let elem_ty_spv = self.lookup_type(elem_ty);
let pat = match self.builder.lookup_const_scalar(fill_byte) {
- Some(fill_byte) => self.memset_const_pattern(&elem_ty_spv, fill_byte as u8),
+ Some(_) => self.memset_const_pattern(&elem_ty_spv, 123),
None => self.memset_dynamic_pattern(&elem_ty_spv, fill_byte.def(self)),
}
.with_type(elem_ty);
and some more that do not trigger any compiletest failures or difftest failures in my personal workarea:
diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs
index d86db1cbd0..b6a867933f 100644
--- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs
+++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs
@@ -290,21 +290,16 @@ macro_rules! simple_uni_op {
}
fn memset_fill_u16(b: u8) -> u16 {
- b as u16 | ((b as u16) << 8)
+ b as u16
}
fn memset_fill_u32(b: u8) -> u32 {
- b as u32 | ((b as u32) << 8) | ((b as u32) << 16) | ((b as u32) << 24)
+ b as u32
}
fn memset_fill_u64(b: u8) -> u64 {
b as u64
| ((b as u64) << 8)
- | ((b as u64) << 16)
- | ((b as u64) << 24)
- | ((b as u64) << 32)
- | ((b as u64) << 40)
- | ((b as u64) << 48)
| ((b as u64) << 56)
}
I discovered this while investigating possible testing for a more general solution to #594.
I suspect the test cases from PR #586 may be able to help avoid this issue if we can adapt these to test memset array fill for u64, i64, u32, etc & check the disassembly. This could give me some more confidence in case we would ever want to refactor some of this memset-related code (someday).
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 crates/rustc_codegen_spirv/src/builder/builder_methods.rs 开始,检查 memset helper 和数组填充路径。改编 PR #586 中的测试用例,以覆盖 u64、i64 和 u32 的 memset 数组填充,然后检查生成的反汇编。完成的标准是测试能够检测出 issue 中描述的变更,且不存在 compiletest 或 difftest 覆盖缺口。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- rust
- 领域
- compilers, testing-qa
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100