LLMigrate: Transforming"Lazy"Large Language Models into Efficient Source Code Migrators

📅 2025-03-31
📈 Citations: 0
Influential: 0
📄 PDF

career value

179K/year
🤖 AI Summary
To address the “lazy omission” problem—structural omission of numerous target functions—and insufficient safety guarantees exhibited by large language models (LLMs) in migrating large C codebases (e.g., the Linux kernel) to Rust, this paper proposes the first function-granularity, call-graph-constrained LLM-assisted migration framework. Our method integrates context-preserving static analysis, GPT-4o–based code generation, compiler feedback–driven iterative repair, and program synthesis–enabled correction, ensuring interface consistency, memory safety, and idiomatic Rust style. Evaluated on three Linux kernel modules—math, sort, and ramfs—the framework achieves high-fidelity translation requiring less than 15% manual edits to target code. It significantly outperforms end-to-end LLM baselines and, for the first time, systematically resolves structural omissions in system-level C-to-Rust migration.

Technology Category

Application Category

📝 Abstract
Rewriting C code in Rust provides stronger memory safety, yet migrating large codebases such as the 32-million-line Linux kernel remains challenging. While rule-based translators (e.g., C2Rust) provide accurate yet largely unsafe Rust programs, recent Large Language Model (LLM) approaches produce more idiomatic, safe Rust programs but frequently exhibit"laziness", omitting significant portions of the target code. To address the issue, in this paper, we present LLMigrate, an LLM-based C-to-Rust translation tool that splits modules into discrete functions, translating them individually, and then reintegrating them. LLMigrate uses static analysis to retain necessary context, pairs GPT-4o (a state-of-the-art LLM) with compiler-driven translation and program-repair techniques for complex core functions, and leverages call-graph-guided translation to ensure consistent interfaces. Evaluations on three representative Linux kernel modules (math, sort, and ramfs) show that LLMigrate requires modifying less than 15% of the target code, significantly outperforming a pure GPT-4o-based migration.
Problem

Research questions and friction points this paper is trying to address.

Addressing laziness in LLMs for C-to-Rust code migration
Ensuring complete and safe Rust translation from C
Improving efficiency in large-scale codebase migration
Innovation

Methods, ideas, or system contributions that make the work stand out.

Splits modules into discrete functions for translation
Uses static analysis to retain necessary context
Leverages call-graph-guided translation for consistent interfaces
🔎 Similar Papers
2024-03-252024 IEEE/ACM First International Conference on AI Foundation Models and Software Engineering (Forge) Conference Acronym:Citations: 22