已开启
feat: disable import lto reflection #601
feat: disable import lto reflection #601
已开启
duan创建于 14 天前
duan
duan仓颉Developer
14 天前

Change Details (Required)

为使 --disable-reflection 在 LTO 场景下同样能够裁剪导入库(import lib)反射信息,本 PR 在 LLVM LTO PostLink 阶段新增 CJDisableImportLibReflection
pass,并在 cangjie_compiler 驱动侧增加对应触发逻辑。

当同时满足以下条件时:

  • 开启 --disable-reflection
  • 启用 LTO
  • 主程序未链接 std.reflect

驱动侧会向 LLVM 透传 --cj-disable-lto-reflection,在 LTO PostLink 阶段触发导入库反射裁剪。具体行为包括:

  • 清除导入库 TypeInfo / TypeTemplate 上的 TF_REFLECTION 标志位
  • 对 reflect operand 采用“按需缩小”的策略:
    • 只有当 compact .dbg 形式能实际缩小 payload 时,才重写为 .dbg global
    • 对已经最小化或不满足降级条件的 reflect payload,保留原 operand,不再强制置空
  • 对可缩小的 reflect global:
    • enum 保留 ctorInfo / modifier / ctorCnt
    • non-enum 保留 fieldNames
  • PackageInfo 仅清除反射有效标志位 FPT_FLAG,不再清空 count 和指针数组,避免破坏 runtime 依赖 GetPackageSize() 的步长扫描逻辑
  • 在 LTO PostLink 阶段清理 rewrite 后已无引用的 reflect globals;在 Full LTO -O0 场景下通过 pass 内部自清理补齐 dead global 删除

同时,本 PR 补齐了 Full/Thin LTO 以及不同优化等级下的挂载逻辑,保证 --disable-reflection 在 LTO 场景下行为一致,并通过 LLT 用例验证了功能正确性和 codesize
收益。

Change Type (Required)

Please describe the type of changes in this Pull Request (reason). Simply save and click the checkbox, or when editing, change [ ] to [x] for the relevant item.

Self-Check of Changes (Required)

Please do not modify or delete the following options. Simply save and click the checkbox, or when editing, change [ ] to [x] for the relevant item.

Platform Differences:

Affected Components:

Local Compilation Verification Results:

Local Test Case Verification Results:

https://gitcode.com/Cangjie/cangjie_compiler/issues/889

likedislike
CLA协议签署
当前Pull Request的提交暂无外部代码贡献者
合并受阻
duanduan仓颉Developer
14 天前 修改了pull request 的描述
cangjie-ci成员
14 天前 评论:

PR创建成功通知 | 感谢您的贡献 🎉

您好!系统已检测到您成功创建 Pull Request(PR),感谢您对项目的支持与参与!以下几点需要您着重关注:

一、PR必须关联Issue ❗️

触发门禁检查的必要步骤:在PR描述框输入Issue完整链接,完成Issue关联

请注意,一个 Issue 不能同时关联同一 base 仓库内同一个分支的多个开启状态的 PR

二、门禁触发规则 🔧

  1. 门禁类型判定:由Issue关联的PR所属代码仓数量决定
    • 关联多个代码仓PR:触发「多仓联合门禁」
    • 关联单个代码仓PR:触发「单仓门禁」
  2. 启动指令与检查范围:需主动回复指令:
    • 回复 "start build":执行Cangjie的主要基础检查,包含commit格式检查、静态告警分析、OAT开源声明检查、多平台构建、单元/集成测试等
    • 关联同一issue的多个PR,仅需在任意一个PR里回复触发一次门禁,该PR门禁通过后,所有PR都会添加Label和测试人
    • 每个pr只能同时运行一条CI流水线,如需重新启动,请先关闭运行中的,再评论触发门禁
    • Markdown修改仅触发文档类构建测试门禁,不会触发Cangjie的编译测试门禁
    • commit 信息格式请遵循:Conventional Commits 规范
    • 请保证每一条 commit 都已添加 Signed-Off-By 信息
    • 回复 "start build cov":执行覆盖率构建工程,生成该提交的增量代码覆盖率报告

三、合入条件 ⚠️

  • 满足最低评审人数,且评审问题需全部解决;
  • 禁止合入本人创建的PR,需由其他协作者操作;
  • 合并前确保关联流水线任务运行成功(build-test-passed);
  • 需求类覆盖率门禁:当关联的 Issue 标题以 [feature]: 开头(需求类 Issue)时,联合提交中属于 cangjie_compilercangjie_runtimecangjie_stdxcangjie_toolsllvm-project 仓库的 PR,必须先回复 "start build cov" 触发增量覆盖率流水线并通过,使 PR 获得 cov-test-passed 标签后方可合入。

四、合并PR ✅

回复 "start merge",CI流水线会自动检查所有关联PR的状态、版本号标签、检视意见密度、兼容性、需求类覆盖率门禁,若所有PR都满足合并条件,则将会同时合并所有PR。若存在不满足合并条件的PR,则不会合并任何PR。

如果希望不进行兼容性相关的检测,请任一合法审查人复制以下内容,在 start merge 前提交评论:

本 pr 不需要兼容性相关检测,对于引发的任何兼容性问题(即由于本 pr 合入将导致用户需适配代码的话),由本人承担。

If you wish to avoid compatibility-related checks, please have any approver copy the following content and submit it as a comment before sending start merge:

This PR does not require compatibility-related checks. For any compatibility issues caused by this PR (i.e., if the integration of this PR will require users to adapt their code), I will take full responsibility.

五、补充说明 📢

likedislike
Ccangjie-ci维护者
14 天前 添加了label:1.3.0-alpha.01waiting-start-build
Ccangjie-ci维护者
14 天前 重置了测试状态
Ccangjie-ci维护者
14 天前 删除了label:waiting-start-build
此处折叠了83条消息 查看更多
cangjie-ci成员
2 小时前 评论:

⚠️ 检测到 Cangjie/cangjie_compiler#2047 的代码发生变化。请回复 start build 重新运行构建/测试门禁。该 PR 关联 Feature Issue,还请回复 start build cov 重新运行增量覆盖率门禁。

⚠️ Code changes detected in Cangjie/cangjie_compiler#2047. Please reply with start build to rerun the build/test gate. This PR is linked to a Feature Issue; please also reply with start build cov to rerun the incremental coverage gate.

likedislike
Ccangjie-ci维护者
2 小时前 添加了label:waiting-start-build
Ccangjie-ci维护者
2 小时前 删除了label:waiting-start-build
cangjie-ci成员
2 小时前 评论:

⚠️ 检测到 Cangjie/cangjie_test#2031 的代码发生变化。请回复 start build 重新运行构建/测试门禁。该 PR 关联 Feature Issue,还请回复 start build cov 重新运行增量覆盖率门禁。

⚠️ Code changes detected in Cangjie/cangjie_test#2031. Please reply with start build to rerun the build/test gate. This PR is linked to a Feature Issue; please also reply with start build cov to rerun the incremental coverage gate.

likedislike
Ccangjie-ci维护者
2 小时前 添加了label:waiting-start-build