Repository navigation
fix(sve): SVE/SME 测试目标关闭严格别名——修复 TBAA 删除 svst1 导致的假 SDC - #298
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
wangxumarshall has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
GCC/Clang 的 TBAA 会把 svst1_f32/f64 写入 uint32_t/uint64_t 缓冲这一刻意 类型双关判为不与整数读别名,进而把整个 SVE 计算连同 store 当死代码删除, 缓冲区保持零值,每条 lane 报出 actual=0x0 的假 SDC。 实证:CI(GCC 16.2.0)sve512_f64_chain_svd / sve512_f64_special_svd / sve512_f32_chain_svd 三例失败;反汇编 CI 产物,其 *_svd_run 内 SVE 指令数 为 0(同 TU 的 _arm 孪生为 6,SVE 计算被整体删除且无外提调用点)。同构最小 复现在本机 GCC 12.3.1 与 Clang 17.0.6 上均可重现,并被同一开关修好。 与 CPU 运行时 VL 无关:main 上该缺陷被 'svcntb() != 64' 硬门在 VL!=512 的 机器上挡成 SKIP,属潜伏缺陷。 影响面限定为 SVE/SME 专属测试库(tests_arm64_sve/_sve2/_sme 与 tests_sve_avx53/_ipsec/_crt),非 SVE 测试与 framework 不受影响。 Signed-off-by: sim <sim@local>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
定义严格别名豁免参数 tests/cpu/meson.build |
新增 sve_bitpattern_exempt 编译参数列表,值为 -fno-strict-aliasing。 |
应用到测试静态库 tests/cpu/arm64/meson.build, tests/cpu/sve/meson.build |
将该参数加入 SVE、SVE2、SME 测试库,以及三个 SVE 测试库的 cpp_args。 |
Priority:
Estimated code review effort: 1 (Trivial) | ~4 minutes
Change: Bug fix
Suggested labels: Review effort 1/5
Merge Risk: 
Minimal · up to c3c7e
-
The change is limited to SVE/SME test compilation, with no established issue requiring a fix before merge.
Architecture risk: 
Low · up to c3c7e
-
The change affects 1 system.
Changed systems:
testsArchitecture concerns
No architecture-level concerns identified.Review details
-
Systems and components
- observed — tests (service) was modified; 3 changed files map to changed impact.
Before / after behavior
- observed — Modified behavior in tests/cpu/arm64/meson.build: 为 SVE 静态库的编译参数新增
sve_bitpattern_exempt。 - observed — Modified behavior in tests/cpu/arm64/meson.build: 为 SVE2 静态库的编译参数新增
sve_bitpattern_exempt。 - observed — Modified behavior in tests/cpu/arm64/meson.build: 为 SME 静态库的编译参数新增
sve_bitpattern_exempt。 - observed — Modified behavior in tests/cpu/meson.build: 新增 SVE/SME 测试专用的严格别名豁免参数
sve_bitpattern_exempt,值为-fno-strict-aliasing;该范围内其余内容是说明性注释。
-
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (3 skipped: 3 unsupported.)
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
🤖 检视机器人覆盖情况
|
User description
问题
CI(GCC 16.2.0)上三个用例稳定失败,报
SDC detected:artifact 显示每条 lane 都是
actual=0x0000000000000000、loop-count: 0,golden 为正常非零值。根因(已用 CI 产物反汇编确证)
这些测试的方法学是「SVE 指令算 → 写入
uint32_t/uint64_t缓冲 → 按位与标量 golden 比较」。svst1_f64(pg, reinterpret_cast<double *>(out), acc)中out的声明类型是uint64_t,构成严格别名(TBAA)违规。GCC/Clang 据此判定该 double 写不与整数读别名,把 store 连同
整个 SVE 计算当死代码删除。
反汇编 CI 产物(
linux-GCC-arm64-binaryartifact):sve512_f64_chain_arm_runsve512_f64_chain_svd_runsve512_f32_chain_arm_runsve512_f32_chain_svd_run被删函数无任何外提调用点(其
bl目标只有 new/delete/memset/log_message/report_fail_msg/test_time_condition)。缓冲区只被
operator new+memset初始化,从未被 SVE 写过 ⇒actual恒 0。不是硅片 SDC,也与运行时 VL 无关。 同构最小复现在本机 GCC 12.3.1 与 Clang 17.0.6 上
均可重现(
-O2下堆缓冲保持 0),且被-fno-strict-aliasing修好。修复
对 SVE/SME 专属测试库的 TU 关闭严格别名(沿用既有的
sve_sanitize_exempt接线点):tests/cpu/meson.build:新增sve_bitpattern_exempt = ['-fno-strict-aliasing']tests/cpu/arm64/meson.build、tests/cpu/sve/meson.build:6 个 SVE/SME 目标接入影响面限于
tests_arm64_sve/_sve2/_sme与tests_sve_avx53/_ipsec/_crt(532 个 TU 中 173 个带该开关),非 SVE 测试与 framework 不受影响;x86-64 零改动。
验证(如实声明边界)
./scripts/build.sh干净、零新警告compile_commands.json核对)exit: pass-e zstd19 -t 2000 -n 1→exit: pass充分证据;充分证据是上面的 CI 产物反汇编 + 双编译器最小复现。最终判据是 CI build-cpu 转绿。
衔接
该缺陷在 main 上潜伏(
main:tests/cpu/arm64/sve512_f64_chain_svd.cpp:127同样写法),只是被
svcntb() != 64硬门在 VL≠512 的机器上挡成 SKIP。all-VL Phase 2 去掉该门后暴露(#283/#286)。Summary by CodeRabbit
PR Type
Bug fix
Description
Disable strict aliasing for SVE/SME tests
Prevent compiler from deleting
svst1storesFix false SDC reports caused by TBAA
Diagram Walkthrough
File Walkthrough
meson.build
定义 SVE/SME 严格别名豁免标志tests/cpu/meson.build
sve_bitpattern_exempt为-fno-strict-aliasingsvst1的机制meson.build
应用严格别名豁免到 arm64 测试tests/cpu/arm64/meson.build
sve_bitpattern_exempt应用到 arm64 的 SVE/SME 测试参数中meson.build
应用严格别名豁免到 sve 构建tests/cpu/sve/meson.build
sve_bitpattern_exempt添加到 sve 相关的 meson 构建配置中