TL;DR
Large Language Models (LLMs) are revolutionizing compiler development, moving beyond traditional handcrafted heuristics. This survey provides a comprehensive taxonomy of how LLMs are integrated into compilers, highlighting their role in democratizing development, discovering new optimizations, and expanding compiler capabilities. While challenges like correctness and scalability remain, hybrid systems and self-improving compilers represent the promising future.
What Problem Does This Paper Address?
For decades, compilers have been the backbone of software development, translating human-readable code into machine-executable programs. This process, especially optimization, has relied heavily on intricate, human-designed heuristics. While machine learning has been applied, it often required extensive feature engineering. The recent surge of LLMs, pre-trained on vast code datasets, offers a paradigm shift. LLMs can understand and generate code with minimal explicit feature engineering, leading to a rapid influx of research applying them to compiler tasks. This paper addresses the need for a structured overview of this rapidly evolving field, aiming to answer: How are LLMs integrated into compilers? What compiler tasks are they tackling? What are the key advancements? And what are the challenges and future opportunities?
Methods
The authors conducted a systematic literature review, filtering through a large pool of papers to curate a corpus of 159 primary studies. They developed a multi-dimensional taxonomy to categorize these studies along four axes:
- Design Philosophy: How the LLM is architecturally integrated (Selector, Translator, Generator).
- LLM Methodology: The technical approach used (Training-Required vs. Training-Free).
- Level of Code Abstraction: The representation of code being processed (Natural Language, High-Level Programming Language, Low-Level IR/Assembly).
- Task Type: The specific compiler-related goal (e.g., optimization, transpilation, repair).
This taxonomy helps structure the analysis and answer the research questions.
Datasets
The paper discusses several datasets used for training and evaluation, including:
- CodeNet: A large-scale, multi-lingual dataset for understanding and transpilation.
- AVATAR: A dataset derived from CodeNet, focusing on parallel function pairs for translation.
- TransCoder-Test: A standardized parallel dataset for translation accuracy.
- PIE (Performance-Improving Edits): A benchmark for optimization tasks.
- MiBench: A suite of embedded C programs for end-to-end compilation.
- KernelBench: A benchmark for GPU kernel generation.
- HumanEval & MBPP: Benchmarks for code generation tasks.
- Defects4J: A dataset of Java bugs for code repair studies.
The paper also notes that many studies curate real open-source repositories or synthesize test cases for specific tasks.
Key Insights and Ideas
- Democratization of Compiler Development: LLMs significantly lower the barrier to entry for creating sophisticated compiler tools, allowing developers to achieve impressive results with less specialized expertise.
- Discovery of Novel Optimization Strategies: LLMs can learn from vast codebases to identify complex patterns and discover optimization strategies that human experts might miss.
- Broadening the Scope of "Compilation": LLMs are expanding the traditional definition of a compiler's role to include tasks like large-scale code transpilation and automated program repair, making compilers more versatile tools for the entire software lifecycle.
- Hybrid Systems are the Future: The most promising near-term direction involves combining the strengths of LLMs with the rigor of traditional compiler algorithms, rather than replacing them entirely.
Key Results
The survey highlights significant progress across various LLM-compiler tasks:
- Code Transpilation: State-of-the-art (SOTA) accuracy (CA@1) has improved substantially, with models achieving over 75% accuracy on benchmarks like TransCoder.
- Neural Compilation: Models are achieving very high computational accuracy (CA), with recent work reaching over 99% on benchmarks like ExeBench.
- GPU Kernel Generation: SOTA models demonstrate significant speedups (averaging 3.12x over torch eager) while maintaining near 100% correctness on benchmarks like KernelBench.
- LLVM IR Optimization: Progress is seen in code size reduction over aggressive compiler flags, with some LLM-based approaches achieving over 8% reduction.
Limitations and Future Work
- Correctness and Verifiability: Ensuring semantic correctness remains a critical challenge due to the probabilistic nature of LLMs. Future work focuses on constrained decoding, translator+verifier hybrids, and formal verification.
- Scalability: Handling large, real-world codebases is difficult, especially for tasks like transpilation. Divide-and-conquer strategies and managing inter-procedural context are active research areas.
- Interpretability and Debuggability: The "black box" nature of LLMs makes their decisions hard to trust. Chain-of-Thought prompting and LLM-as-Generator approaches are being explored.
- Performance and Cost-Effectiveness: The inference cost of large models can be substantial. Future work involves using smaller, specialized models or employing LLMs as accelerators for existing processes.
- Standardized Benchmarks: The field needs more standardized benchmarks, particularly for large-scale, project-level evaluations, to facilitate fair comparisons and track progress.
- Hybrid Compiler Systems: Combining LLMs with traditional compiler algorithms is seen as a key path forward.
- Self-Improving Compilers: Creating compilers that can permanently learn new optimization strategies discovered by LLMs is a significant future opportunity.
- Interactive Developer Tools: LLMs could transform IDEs, offering intelligent assistance for code optimization, refactoring, and debugging.
Summary updated