Lune

ICLR2023Top-tier venue

Code Translation with Compiler Representations

Marc Szafraniec, Baptiste Rozière, Hugh Leather, Patrick Labatut, François Charton, Gabriel Synnaeve

Abstract

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.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

28 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Lost in Translation: A Study of Bugs Introduced by Large Language Models while Translating Code cites Unsupervised Translation of Programming Languages
  • Lost in Translation: A Study of Bugs Introduced by Large Language Models while Translating Code cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Lost in Translation: A Study of Bugs Introduced by Large Language Models while Translating Code cites Leveraging Automated Unit Tests for Unsupervised Code Translation
  • Multi-lingual Evaluation of Code Generation Models cites Unsupervised Translation of Programming Languages
  • Multi-lingual Evaluation of Code Generation Models cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Multi-lingual Evaluation of Code Generation Models cites GraphCodeBERT: Pre-training Code Representations with Data Flow
  • Exploring and Unleashing the Power of Large Language Models in Automated Code Translation cites Unsupervised Translation of Programming Languages
  • Exploring and Unleashing the Power of Large Language Models in Automated Code Translation cites Leveraging Automated Unit Tests for Unsupervised Code Translation
  • CodeBERT: A Pre-Trained Model for Programming and Natural Languages cites Learning and Evaluating Contextual Embedding of Source Code
  • Learning and Evaluating Contextual Embedding of Source Code cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Scalable, Validated Code Translation of Entire Projects using Large Language Models cites Lost in Translation: A Study of Bugs Introduced by Large Language Models while Translating Code
  • Scalable, Validated Code Translation of Entire Projects using Large Language Models cites Unsupervised Translation of Programming Languages
  • Scalable, Validated Code Translation of Entire Projects using Large Language Models cites Leveraging Automated Unit Tests for Unsupervised Code Translation
  • Leveraging Automated Unit Tests for Unsupervised Code Translation cites Unsupervised Translation of Programming Languages
  • Leveraging Automated Unit Tests for Unsupervised Code Translation cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Leveraging Automated Unit Tests for Unsupervised Code Translation cites GraphCodeBERT: Pre-training Code Representations with Data Flow
  • Leveraging Automated Unit Tests for Unsupervised Code Translation cites Learning and Evaluating Contextual Embedding of Source Code
  • GALLa: Graph Aligned Large Language Models for Improved Source Code Understanding cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • GALLa: Graph Aligned Large Language Models for Improved Source Code Understanding cites GraphCodeBERT: Pre-training Code Representations with Data Flow
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers28

  1. Lost in Translation: A Study of Bugs Introduced by Large Language Models while Translating CodeRangeet Pan, Ali Reza Ibrahimzada, Rahul Krishna, Divya Sankar et al.ICSE 2024 · 96 citations
  2. Exploring and Unleashing the Power of Large Language Models in Automated Code TranslationZhen Yang, Fang Liu, Zhongxing Yu, Jacky Wai Keung et al.FSE 2024 · 72 citations
  3. Multi-lingual Evaluation of Code Generation ModelsBen Athiwaratkun, Sanjay Krishna Gouda, Zijian Wang, Xiaopeng Li et al.ICLR 2023 · 28 citations
  4. Scalable, Validated Code Translation of Entire Projects using Large Language ModelsHanliang Zhang, Cristina David, Meng Wang, Brandon Paulsen et al.PLDI 2025 · 15 citations
  5. GALLa: Graph Aligned Large Language Models for Improved Source Code UnderstandingZiyin Zhang, Hang Yu, Sage Lee, Peng Di et al.ACL 2025 · 11 citations

Builds on5

  1. CodeBERT: A Pre-Trained Model for Programming and Natural LanguagesZhangyin Feng, Daya Guo, Duyu Tang, Nan Duan et al.EMNLP Findings 2020 · 2,828 citations
  2. GraphCodeBERT: Pre-training Code Representations with Data FlowDaya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng et al.ICLR 2021 · 1,644 citations
  3. Unsupervised Translation of Programming LanguagesBaptiste Rozière, Marie-Anne Lachaux, Lowik Chanussot, Guillaume LampleNeurIPS 2020 · 606 citations
  4. Learning and Evaluating Contextual Embedding of Source CodeAditya Kanade, Petros Maniatis, Gogul Balakrishnan, Kensen ShiICML 2020 · 438 citations
  5. Leveraging Automated Unit Tests for Unsupervised Code TranslationBaptiste Rozière, Jie Zhang, François Charton, Mark Harman et al.ICLR 2022 · 161 citations

Related papers

  1. Program Translation via Code DistillationYufan Huang, Mengnan Qi, Yongqiang Yao, Maoquan Wang et al.EMNLP 2023 · 7 citations
  2. VERT: Polyglot Verified Equivalent Rust Transpilation with Large Language ModelsAidan Z. H. Yang, Yoshiki Takashima, Brandon Paulsen, Josiah Dodds et al.ASE 2025 · 1 citation
  3. IRCoder: Intermediate Representations Make Language Models Robust Multilingual Code GeneratorsIndraneil Paul, Goran Glavas, Iryna GurevychACL 2024
  4. RustRepoTrans: Repository-level Context Code Translation Benchmark Targeting RustGuangsheng Ou, Mingwei Liu, Yuxuan Chen, Yanlin Wang et al.ASE 2025 · 1 citation
  5. Semi-Supervised Code Translation Overcoming the Scarcity of Parallel Code DataMing Zhu, Mohimenul Karim, Ismini Lourentzou, Daphne YaoASE 2024 · 2 citations
Dusk over the sea between two cliffs drawn in fine vertical lines