一句话:提出首个自动识别并修复 LLVM 优化中调试位置更新错误的技术,并落地为 MetaLoc。
优化编译器(如 LLVM)需在代码变换后更新调试信息,但该过程依赖人工且易错,可能造成调试位置错误或丢失;已有黑盒测试只能发现 bug,无法定位根因或修复。本文提出首个健壮化 LLVM 调试信息更新的技术。核心观察是原始与优化程序的调试位置须满足一致性关系,避免优化在控制流路径上引入多余调试位置。作者提出控制流一致性分析:观察 LLVM 优化 pass 执行并分析待优化程序控制流图中的调试位置,确定参考更新;再以此检查开发者手写更新,不一致时以参考更新为骨架指导修复。工具 MetaLoc 报告并修复 46 个未知错误,相关补丁和 22 个回归测试已合入 LLVM,并促成官方文档两处修正。
Optimizing compilers, such as LLVM, generate debug information in machine code to aid debugging. This information is particularly important when debugging optimized code, as modern software is often compiled with optimization enabled. However, properly updating debug information to reflect code transformations during optimization is a complex task that often relies on manual effort. This complexity makes the process prone to errors, which can lead to incorrect or lost debug information. Finding and fixing potential debug information update errors is vital to maintaining the accuracy and reliability of the overall debugging process. To our knowledge, no existing techniques can rectify debug information update errors in LLVM. While black-box testing approaches can find such bugs, they can neither pinpoint the root causes nor suggest fixes. To fill the gap, we propose the first technique to robustify debug information updates in LLVM. In particular, our robustification approach can find and fix incorrect debug location updates. Central to our approach is the observation that the debug locations in the original and optimized programs must satisfy a conformance relation. The relation ensures that LLVM optimizations do not introduce extraneous debug location information on the control-flow paths of the optimized programs. We introduce control-flow conformance analysis, a novel approach that determines the reference updates ensuring the conformance relation by observing the execution of LLVM optimization passes and analyzing the debug locations in the control-flow graphs of programs under optimization. The determined reference updates are then used to check developer-written updates in LLVM. When discrepancies arise, the reference updates serve as the update skeletons to guide the fixing. We realized our approach as a tool named M eta L oc which determines proper debug location updates for LLVM optimizations. More importantly, with M eta L oc , we have reported and patched 46 previously unknown update errors in LLVM. All the patches, along with 22 new regression tests, have been merged into the LLVM codebase, effectively improving the accuracy and reliability of debug information in all programs optimized by LLVM. Furthermore, our approach uncovered and led to corrections in two issues within LLVM’s official documentation on debug information updates.
@article{paperbot3091,
title = {Robustifying Debug Information Updates in LLVM via Control-Flow Conformance Analysis},
author = {Shan Huang and Jingjing Liang and Ting Su and Qirun Zhang},
journal = {Proceedings of the ACM on Programming Languages},
volume = {9},
number = {PLDI},
year = {2025},
doi = {10.1145/3729267}
}