arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2404.16041cs.PLcs.AIcs.LG
收藏

Forklift:一个可扩展的神经 Lifter

Forklift: An Extensible Neural Lifter

University of Edinburgh(爱丁堡大学);School of Informatics(信息学院)

Jordi Armengol-Estapé, Rodrigo C. O. Rocha, Jackson Woodruff, Pasquale Minervini, Michael F. P. O'Boyle

AI总结:

提出首个神经 lifter Forklift,利用 Transformer 学习将汇编翻译为 LLVM IR,通过微调编码器支持新 ISA,在基准测试中翻译量远超手写工具和 GPT-4。

摘要:

将遗留软件跨不同指令集架构(ISA)进行迁移的不断增长的需求,推动了汇编到汇编翻译器的发展,以在它们各自的汇编语言之间进行映射。然而,开发这些工具需要大量的工程工作。最先进的方法使用 lifting,这是一种将源汇编代码翻译为架构无关的中间表示(IR)(例如 LLVM IR)并使用现有的编译器将 IR 重新编译为目标 ISA 的技术。然而,这些 lifter 所采用的手写规则对用于生成代码的特定编译器和优化级别很敏感,并且需要大量的工程工作来支持每个新的 ISA。我们提出了 Forklift,这是第一个使用 token 级编码器-解码器 Transformer 学习如何将汇编翻译为 LLVM IR 的神经 lifter。我们展示了如何通过微调汇编编码器并冻结 IR 解码器来逐步增加对新 ISA 的支持,从而提高整体准确性和效率。我们收集了跨编译器和优化级别的数百万个并行的 LLVM IR、x86、ARM 和 RISC-V 程序来训练 Forklift,并建立了一个基于输入/输出的准确性测试工具。我们在两个具有挑战性的基准套件上评估了 Forklift,翻译的 x86 程序比最先进的手写 lifter 多 2.5 倍,比 GPT-4 多 4.4 倍,并且支持从新的 ISA 进行翻译。

英文摘要:

The escalating demand to migrate legacy software across different Instruction Set Architectures (ISAs) has driven the development of assembly-to-assembly translators to map between their respective assembly languages. However, the development of these tools requires substantial engineering effort. State-of-the-art approaches use lifting, a technique where source assembly code is translated to an architecture-independent intermediate representation (IR) (for example, the LLVM IR) and use a pre-existing compiler to recompile the IR to the target ISA. However, the hand-written rules these lifters employ are sensitive to the particular compiler and optimization level used to generate the code and require significant engineering effort to support each new ISA. We propose Forklift, the first neural lifter that learns how to translate assembly to LLVM IR using a token-level encoder-decoder Transformer. We show how to incrementally add support to new ISAs by fine tuning the assembly encoder and freezing the IR decoder, improving the overall accuracy and efficiency. We collect millions of parallel LLVM IR, x86, ARM, and RISC-V programs across compilers and optimization levels to train Forklift and set up an input/output-based accuracy harness. We evaluate Forklift on two challenging benchmark suites and translate 2.5x more x86 programs than a state-of-the-art hand-written lifter and 4.4x more x86 programs than GPT-4 as well as enabling translation from new ISAs.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑