paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Duplo: a framework for OCaml post-link optimisation

Duplo:一个 OCaml 链接后优化框架
ICFP 4(ICFP)2020匹配度 2/10 · 该论文属于纯编译器与程序分析方向,涉及 LLIR、SSA、points-to 分析等静态分析技术,但未涉及用户核心关注的 LLM/Agent、AI 与静态分析交叉、浮点程序分析或贝叶斯程序分析,因此仅与广义 PL/程序分析有边缘关联。引用 2 inbox
Nandor Licker, Timothy M. Jones
dblp: 2026-09-10crossref: 2026-09-10

AI 速览

一句话:提出 Duplo 框架,在低层中间表示 LLIR 上对 OCaml 程序及其 C 依赖做跨语言链接后优化,取得约 7% 加速并使代码体积至少减少 15%。

链接后优化能在程序链接后利用全局信息优化代码,但已有工具多针对目标相关机器码,无法跨 OCaml 与 C 的 FFI 边界。Duplo 提出低层中间表示 LLIR,统一表示 OCaml 程序及其 C 依赖,并在其上实现链接后优化器 LLIR-OPT,通过 SSA 变换、跨语言指向分析与内联,将 C 方法嵌入 OCaml 调用者,再经改造的 LLVM amd64 后端完成兼顾垃圾回收的代码生成。在众多广泛使用的 OCaml 应用及编译器基准上,相较原生 OCaml 后端取得约 7% 加速,代码体积减少至少 15%。

问题
现有链接后优化器通常只处理目标相关机器码,难以跨越 OCaml 与 C 的 FFI 边界,因而无法进行跨语言分析并错失全局优化机会。
方法
设计 LLIR 中间表示统一刻画 OCaml 程序及其 C 依赖,LLIR-OPT 在其上执行 SSA 变换、指向分析与跨语言内联,再经修改后的 LLVM amd64 后端完成支持垃圾回收的代码生成。
评估
在大量广泛使用的 OCaml 应用以及 OCaml 编译器的微/宏基准测试集上评估,测得约 7% 的加速和至少 15% 的代码体积缩减。
原文摘要(Abstract)

We present a novel framework, Duplo , for the low-level post-link optimisation of OCaml programs, achieving a speedup of 7% and a reduction of at least 15% of the code size of widely-used OCaml applications. Unlike existing post-link optimisers, which typically operate on target-specific machine code, our framework operates on a Low-Level Intermediate Representation (LLIR) capable of representing both the OCaml programs and any C dependencies they invoke through the foreign-function interface (FFI). LLIR is analysed, transformed and lowered to machine code by our post-link optimiser, LLIR-OPT. Most importantly, LLIR allows the optimiser to cross the OCaml-C language boundary, mitigating the overhead incurred by the FFI and enabling analyses and transformations in a previously unavailable context. The optimised IR is then lowered to amd64 machine code through the existing target-specific code generator of LLVM, modified to handle garbage collection just as effectively as the native OCaml backend. We equip our optimiser with a suite of SSA-based transformations and points-to analyses capable of capturing the semantics and representing the memory models of both languages, along with a cross-language inliner to embed C methods into OCaml callers. We evaluate the gains of our framework, which can be attributed to both our optimiser and the more sophisticated amd64 backend of LLVM, on a wide-range of widely-used OCaml applications, as well as an existing suite of micro- and macro-benchmarks used to track the performance of the OCaml compiler.

链接与引用

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

BibTeX
@article{LickerJ20,
  title = {Duplo: a framework for OCaml post-link optimisation},
  author = {Nandor Licker and Timothy M. Jones},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {4},
  number = {ICFP},
  year = {2020},
  doi = {10.1145/3408980}
}