编译器工程师 - 宋旭陶
GitHub:dianqk 邮箱:dianqk@dianqk.net 博客:dianqk.blog
个人简介
Rust compiler team、MIR 优化工作组和 LLVM 工作组成员。主要使用 Rust/C++,参与 Rust MIR 与代码生成、LLVM IR 优化与后端开发。
代表性开源贡献
Rust MIR 与代码生成
- 实现 GVN 中的 Clone-to-Copy 优化:识别逐字段复制再重建聚合值的模式,将满足约束的操作简化为整体复制,优化部分派生
Clone。#128299rust-lang/rust #128299Simplify the canonical clone method and the copy-like forms to copy - 为推进该优化,引入 MIR 语句级调试信息,表达被移除的引用语句;重构
MatchBranchSimplification,将 GVN 生成的规范枚举克隆分支合并为复制语句。#142771rust-lang/rust #142771Introduce debuginfo to statements in MIR、#148034rust-lang/rust #148034Simplify the canonical enum clone branches to a copy statement - 实现
SsaRangePropagationPass,利用 switch、assert、assume 确定的 SSA 已知单值,在满足控制流约束的位置将操作数替换为常量。#150309rust-lang/rust #150309New MIR Pass: SsaRangePropagation - 修正 GVN 传播引用的限制,补充处理嵌套共享引用;修复间接指针参数按值传递时遗漏必要复制的问题。#150485rust-lang/rust #150485GVN: Only propagate borrows from SSA locals、#157346rust-lang/rust #157346 GVN: Don't assume nested shared references are read-only.、#155343rust-lang/rust #155343codegen: Copy to an alloca when the argument is neither by-val nor by-move for indirect pointer.
LLVM IR 优化与正确性
- 扩展 SimplifyCFG,将公共指令上提用于 switch 多后继分支,并支持将环绕连续的 case 集合折叠为整数比较。#67077llvm/llvm-project #67077Reland "[SimplifyCFG] Hoist common instructions on switch" 、#161000llvm/llvm-project #161000 [SimplifyCFG] Fold the contiguous wrapping cases into ICmp.
- 改进 MemCpyOpt,按实际复制区域及偏移转发
memcpy;在 EarlyCSE 中按基址和常量偏移识别等价 GEP。#87190llvm/llvm-project #87190 [MemCpyOpt] Forward `memcpy` based on the actual copy memory location.、#65875llvm/llvm-project #65875[EarlyCSE] Compare GEP instructions based on offset - 定位并修复 Rust bootstrap 中的 LLVM 错误编译,解除团队其他贡献者的开发阻塞;包括 MemCpyOpt 别名元数据和 LVI/CVP 的 undef 处理问题。#67539llvm/llvm-project #67539[MemCpyOpt] Merge alias metadatas when replacing arguments、#68190llvm/llvm-project #68190[LVI][CVP] Treat undef like a full range;定位过程
LLVM 后端优化与修复
- 2021 年首个 LLVM 提交:修复 MachineOutliner 对同一指令中寄存器隐式 use/def 的处理,避免 AArch64 多轮 outlining 错误覆盖仍存活的参数寄存器。提交llvm/llvm-project · 1e9fa0b12a76Fix the side effect of outlined function when the register is implicit use and implicit-def in the same instruction.、D112911LLVM · D112911Fix the side effect of outlined function when the register is implicit use and implicit-def in the same instruction.
- 调整 TailDuplicator,限制复杂控制流图的尾复制规模;跟进由此引入的解释器性能回退,参考 GCC 改进 computed goto 策略并验证 Ajla、CPython。#78582llvm/llvm-project #78582[TailDuplicator] Add maximum predecessors and successors to consider tail duplicating blocks、#114990llvm/llvm-project #114990[TailDuplicator] Do not restrict the computed gotos、#132536llvm/llvm-project #132536[TailDuplicator] Determine if computed gotos using `blockaddress`
- 修复 RegisterCoalescer 重复访问已删除指令的问题;为 SPARC 栈槽读写补充访问大小信息,供 StackSlotColoring 使用。#79820llvm/llvm-project #79820[RegisterCoalescer] Clear instructions not recorded in `ErasedInstrs` but erased、#182674llvm/llvm-project #182674[SPARC] Set how many bytes load from or store to stack slot
其他贡献与社区参与
- 修复 Swift 的 LTO 调试信息与 Linux 回溯解析问题,以及 wasm3 的栈释放与局部变量计数溢出。Swift#67077swiftlang/swift #67077[IRGen][DebugInfo] split method declaration and definition.、#67592swiftlang/swift #67592[Backtracing][Linux] Support the DW_AT_specification attribute.、wasm3#436wasm3/wasm3 #436Fix the issue of incorrectly freeing the stack address when unwinding local functions.、#500wasm3/wasm3 #500Change `numLocalBytes` to `u32`
- 参与 Rust MIR、代码生成与 LTO 评审,涉及数据流分析、枚举判别值生成和 linker-plugin LTO。#142707rust-lang/rust #142707Apply effects to `otherwise` edge in dataflow analysis、#143784rust-lang/rust #143784Simplify discriminant codegen for niche-encoded variants which don't wrap across an integer boundary、#136840rust-lang/rust #136840Fix linker-plugin-lto only doing thin lto
- 参与 Rust LLVM 分支的修复回移与 CI 配置;修复 NixOS rustup 使用 Rust 自带链接器时的打包集成问题。Rust LLVM#182rust-lang/llvm-project #182Backport #145690, #146068 and #144058、#186rust-lang/llvm-project #186[rust] Add CI Checks to Rust fork、Nixpkgs#314268NixOS/nixpkgs #314268rustup: addressing a series of issues encountered while using Rust's self-contained `ld.lld`