paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Semantic Analysis of Macro Usage for Portability

宏使用可移植性的语义分析
ICSE Proceedings of the IEEE/ACM 46th International Conference on Software Engineering2024匹配度 3/10 · 论文属于程序分析与抽象解释方向,结合宏语义分析、可移植性迁移和真实工业项目落地,工程与问题驱动特征与用户偏好相符;但它不涉及 LLM/Agent、浮点程序分析或贝叶斯程序分析,也未将静态分析用于 ML/Agentic 系统,因此与用户当前核心研究问题仅有弱相关。引用 3 inbox
Brent Pappas, Paul Gazzillo
crossref: 2026-09-12

AI 速览

一句话:提出首个宏可移植性分析框架与工具 Maki,将宏行为分解为26个属性,以94%准确率识别易移植宏并指导C代码迁移。

将 C 语言迁移到 Rust、Checked C 或 Go 等更安全语言时,现有工具通常先预处理再移植,导致代码丢失宏抽象、难以辨认。论文提出首个宏使用可移植性分析框架,将宏行为分解为 26 个细粒度属性,并实现程序分析工具 Maki 在真实代码中识别这些属性。Maki 识别准确率达 94%,应用于 21 个程序、共 86,199 个宏定义。结果显示真实宏比此前认为的更容易移植:超过三分之一(37%)易于移植,平均比先前工作多发现 2 倍易移植宏,最佳情况达 7 倍。作者还依据 Maki 输出手工移植三个真实程序中的宏,并向 Linux 维护者提交涉及 11 个宏的补丁,其中 9 个已被接受。

问题
C 宏的语义不同于普通函数,现有 C 到安全语言移植工具先预处理源文件,会破坏宏抽象;因此需要理解宏行为以识别可移植性并指导等价构造移植。
方法
将宏行为分解为 26 个细粒度属性,实现静态程序分析工具 Maki,在真实 C 代码中识别这些属性并给出移植提示。
评估
在 21 个程序、86,199 个宏定义上评估,Maki 识别准确率 94%,发现 37% 宏易移植,平均较先前工作多 2 倍(最佳 7 倍);并手工移植宏,提交 Linux 补丁 11 个,9 个被接受。
原文摘要(Abstract)

C is an unsafe language. Researchers have been developing tools to port C to safer languages such as Rust, Checked C, or Go. Existing tools, however, resort to preprocessing the source file first, then porting the resulting code, leaving barely recognizable code that loses macro abstractions. To preserve macro usage, porting tools need analyses that understand macro behavior to port to equivalent constructs. But macro semantics differ from typical functions, precluding simple syntactic transformations to port them. We introduce the first comprehensive framework for analyzing the portability of macro usage. We decompose macro behavior into 26 fine-grained properties and implement a program analysis tool, called Maki, that identifies them in real-world code with 94% accuracy. We apply Maki to 21 programs containing a total of 86,199 macro definitions. We found that real-world macros are much more portable than previously known. More than a third (37%) are easy-to-port, and Maki provides hints for porting more complicated macros. We find, on average, 2x more easy-to-port macros and up to 7x more in the best case compared to prior work. Guided by Maki's output, we found and hand-ported macros in three real-world programs. We submitted patches to Linux maintainers that transform eleven macros, nine of which have been accepted.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot11322,
  title = {Semantic Analysis of Macro Usage for Portability},
  author = {Brent Pappas and Paul Gazzillo},
  booktitle = {ICSE},
  year = {2024},
  doi = {10.1145/3597503.3623323}
}