Skip to content

Fix PTOAS warning build failures#675

Merged
zhangstevenunity merged 3 commits into
hw-native-sys:mainfrom
FangRui0:fix_compile_warning
May 19, 2026
Merged

Fix PTOAS warning build failures#675
zhangstevenunity merged 3 commits into
hw-native-sys:mainfrom
FangRui0:fix_compile_warning

Conversation

@FangRui0
Copy link
Copy Markdown
Contributor

@FangRui0 FangRui0 commented May 15, 2026

修复 macOS/Clang 和gitcode/gcc下 ninja -C build install 的 -Werror 构建失败。

主要清理了几处会被 Clang 视为错误的编译告警:

  1. 去掉已覆盖全部枚举值的 switch 中多余的 default 分支,并补充必要的兜底返回
  2. 补全 AddressSpace 的 Zero / GM 分支映射,消除未处理枚举告警
  3. 删除 PTOToEmitC 中未使用的 lambda capture
  4. 将当前未使用但保留设计意图的字段、常量和辅助函数显式标记为 [[maybe_unused]]

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several code cleanups and robustness improvements, including the addition of [[maybe_unused]] attributes to suppress compiler warnings, the removal of unnecessary lambda captures, and the refactoring of switch statements to move default return values outside the blocks. Additionally, stringifyLocFromMemorySpace was updated with a null check and new address space mappings. Feedback was provided regarding the mapping of AddressSpace::Zero to "illegal", which may cause issues with IR round-tripping since it is treated as a valid memory space elsewhere in the codebase.

Comment thread lib/PTO/IR/PTOTypeDefs.cpp Outdated
if (!asAttr)
return "illegal";
switch (asAttr.getAddressSpace()) {
case AddressSpace::Zero: return "illegal";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

stringifyLocFromMemorySpace 中将 AddressSpace::Zero 映射为 "illegal" 可能会导致 IR 在序列化后无法正确解析回原始状态(Round-tripping)。由于 PTOToEmitC.cpp 中将 AddressSpace::Zero 处理为有效的全局内存空间(映射到 __gm__),建议为其提供一个有效的字符串表示(如 "gm""zero"),除非该值仅作为内部哨兵使用且不应出现在序列化后的 IR 中。

@reedhecre
Copy link
Copy Markdown

reedhecre commented May 15, 2026

Codex Review

该评论由 review 机器人自动更新。

  • PR: Fix PTOAS warning build failures #675 Fix PTOAS Clang warning build failures
  • Author: FangRui0
  • Base/Head: main / fix_compile_warning
  • Head SHA: bb0da65a150a
  • Trigger: PR 有新提交
  • Generated At: 2026-05-19T04:41:34Z
  • Previous Head SHA: 5aca246a8656
  • Status: completed

Summary

未检查到 PR #675 存在问题

Findings

No issues found.

@FangRui0 FangRui0 force-pushed the fix_compile_warning branch 6 times, most recently from 5aca246 to 2d79268 Compare May 19, 2026 02:45
@FangRui0 FangRui0 force-pushed the fix_compile_warning branch from 8de3d31 to 460cafc Compare May 19, 2026 03:39
@FangRui0 FangRui0 changed the title Fix PTOAS Clang warning build failures Fix PTOAS warning build failures May 19, 2026
@zhangstevenunity zhangstevenunity merged commit 72e3144 into hw-native-sys:main May 19, 2026
11 checks passed
@reedhecre
Copy link
Copy Markdown

A5 板测成功

  • 触发方式:merged
  • 源码提交:72e314460b54
  • 结果汇总:OK 17 / FAIL 0 / SKIP 0
  • 日志:/root/ptoas-board-monitor-a5/logs/20260519_153405_merged_pr675.log
  • 结果 TSV:/root/ptoas-board-monitor-a5/logs/20260519_153405_merged_pr675.tsv

@reedhecre
Copy link
Copy Markdown

A3 板测完成(有跳过)

  • 触发方式:merged
  • 源码提交:72e314460b54
  • 结果汇总:OK 212 / FAIL 0 / SKIP 2
  • 日志:/home/zhongxuan/ptoas-board-monitor/runtime/logs/20260519_154905_merged_pr675.log
  • 结果 TSV:/home/zhongxuan/ptoas-board-monitor/runtime/logs/20260519_154905_merged_pr675.tsv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants