{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/code-translation-with-compiler","title":"Code Translation with Compiler Representations","arxiv_id":"2207.03578","date":"2022-06-30","proceeding":null,"authors":["Marc Szafraniec","Baptiste Roziere","Hugh Leather","Francois Charton","Patrick Labatut","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.","url_abs":"https://arxiv.org/abs/2207.03578v5","url_pdf":"https://arxiv.org/pdf/2207.03578v5.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"code-translation-with-compiler","repo_url":"https://github.com/facebookresearch/CodeGen","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"code-translation","task_name":"Code Translation"},{"task_slug":"machine-translation","task_name":"Machine Translation"},{"task_slug":"nmt","task_name":"NMT"},{"task_slug":"translation","task_name":"Translation"}],"methods":[{"method_slug":"test","method_name":"Test"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2207.03578","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2207.03578"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/facebookresearch/CodeGen","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":6},"by_repo_kind":{"listed":{"samples":6,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":6,"samples":[{"code_sha256_prefix":"bed57f6001f65a3e","entry":"clean_err_output","repo":"facebookresearch/CodeGen","repo_kind":"listed","path":"codegen_sources/code_runners/utils.py","file_url":"https://github.com/facebookresearch/CodeGen/blob/HEAD/codegen_sources/code_runners/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"bed57f6001f65a3e"}},{"code_sha256_prefix":"eebe99a6c4082bca","entry":"demangle_names_cpp","repo":"facebookresearch/CodeGen","repo_kind":"listed","path":"codegen_sources/IR_tools/utils_ir.py","file_url":"https://github.com/facebookresearch/CodeGen/blob/HEAD/codegen_sources/IR_tools/utils_ir.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"eebe99a6c4082bca"}},{"code_sha256_prefix":"a985bcb5f48a99e5","entry":"extract_dict","repo":"facebookresearch/CodeGen","repo_kind":"listed","path":"codegen_sources/dataloaders/utils.py","file_url":"https://github.com/facebookresearch/CodeGen/blob/HEAD/codegen_sources/dataloaders/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"a985bcb5f48a99e5"}},{"code_sha256_prefix":"e0ec2aae48ea0c51","entry":"limit_virtual_memory","repo":"facebookresearch/CodeGen","repo_kind":"listed","path":"codegen_sources/code_runners/utils.py","file_url":"https://github.com/facebookresearch/CodeGen/blob/HEAD/codegen_sources/code_runners/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"e0ec2aae48ea0c51"}},{"code_sha256_prefix":"bc7150313b7bed0d","entry":"split_python_code","repo":"facebookresearch/CodeGen","repo_kind":"listed","path":"codegen_sources/dataloaders/utils.py","file_url":"https://github.com/facebookresearch/CodeGen/blob/HEAD/codegen_sources/dataloaders/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"bc7150313b7bed0d"}},{"code_sha256_prefix":"781797e5f4a5b6ec","entry":"timeout","repo":"facebookresearch/CodeGen","repo_kind":"listed","path":"codegen_sources/IR_tools/utils_ir.py","file_url":"https://github.com/facebookresearch/CodeGen/blob/HEAD/codegen_sources/IR_tools/utils_ir.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"781797e5f4a5b6ec"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}