Code Translation with Compiler Representations
By Marc Szafraniec, Baptiste Rozière, Hugh Leather Francois Charton, Patrick Labatut, Gabriel Synnaeve. 2022
95 citations recorded by the source corpus.
In this paper, we leverage low-level compiler intermediate representations (IR) to improve code translation. Traditional transpilers rely on syntactic information and handcrafted rules, which limits their applicability and produces unnatural-looking code. Applying neural machine translation (NMT) approaches to code has successfully broadened the set of programs on which one can get a natural-looking translation. However, they treat the code as sequences of text tokens, and still do not differentiate well enough between similar pieces of code which have different semantics in different languages. The consequence is low quality translation, reducing the practicality of NMT, and stressing the need for an approach significantly increasing its accuracy. Here we propose to augment code translation with IRs, specifically LLVM IR, with results on the C++, Java, Rust, and Go languages. Our method improves upon the state of the art for unsupervised code translation, increasing the number of correct translations by 11% on average, and up to 79% for the Java ->Rust pair with greedy decoding. We extend previous test sets for code translation, by adding hundreds of Go and Rust functions. Additionally, we train models with high performance on the problem of IR decompilation, generating programming source code from IR, and study using IRs as intermediary pivot for translation.
Subfields: Artificial Intelligence, Information Systems, Code Generation & Program Synthesis
How researchers see this paper
The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.
In Artificial Intelligence
In Information Systems
- Gabriel Synnaeve
- Fei Huang
- Chang Zhou
- Jingren Zhou
- Nicolas Usunier
- Xuancheng Ren
- Jianwei Zhang
- Wenhan Xiong
In Code Generation & Program Synthesis
Citations in the corpus
- Code Llama: Open Foundation Models for Code (2023, methodology): “These tasks include code summarization, refinement, translation (Rozière et al., 2020; 2021; Szafraniec et al., 2023) fixing bugs (Yasunaga & Liang, 2021; Zhang et al., 2022a; Prenner et al., 2022), fixing build errors (Tarlow et al., 2020) or generating unit tests (Tufano et al., 2020; Li et al.,…”
- Qwen Technical Report (2023, background): “, 2023a), code translation (Szafraniec et al., 2023), bug fixing (Muennighoff et al.”