Code Translation with Compiler Representations

要約

タイトル:コンパイラ表現を使用したコード変換

要約:
– 従来の変換プログラムは、構文情報や手作りのルールに依存するため、適用範囲が制限され、不自然なコードを生成する問題がある。
– 深層学習を用いた自然言語処理手法をコードに適用することで、より自然な変換プログラムが可能になったが、テキストトークンの並びとして扱われるため、異なる言語で異なる意味を持つ似たようなコードを区別できていない。
– そこで、本論文では、LLVM IRのような低レベルのコンパイラ独自の表現をコード変換に取り入れ、C++、Java、Rust、Goなどの言語で改善を図る。
– 実験結果では、従来のプログラムよりも11%以上の正確な変換が可能になり、Java -> Rustのペアではグリーディー探索を使って79%の向上が確認された。
– また、新しいプログラムとして、数百のGoとRustの関数を追加し、IRの中間ピボットとしての利用を研究している。

要約(オリジナル)

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.

arxiv情報

著者 Marc Szafraniec,Baptiste Roziere,Hugh Leather,Francois Charton,Patrick Labatut,Gabriel Synnaeve
発行日 2023-04-24 10:12:18+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, OpenAI

カテゴリー: cs.CL, cs.LG, cs.PL パーマリンク