Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Code
- URL: http://arxiv.org/abs/2607.13921v2
- Date: Thu, 16 Jul 2026 21:41:50 GMT
- Title: Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Code
- Abstract summary: We introduce generative compilation, the first approach to obtaining compiler feedback on partial programs during generation.<n>We show that generative compilation reduces non-compiling outputs and improves functional correctness, relative to standard post-generation feedback.
- Score: 43.07697210931911
- License: http://creativecommons.org/licenses/by/4.0/
- Abstract: Languages with rich static semantics, such as Rust, provide stronger guarantees for AI-generated code, but their strictness makes generation more difficult. Off-the-shelf compilers can provide useful feedback post-generation, but does not guide intermediate generation steps, such as those during autoregressive LLM decoding. Constrained decoding intervenes earlier by rejecting invalid tokens during sampling, but requires white-box model access and costly reimplementation for semantic constraints. We introduce generative compilation, the first approach to obtaining compiler feedback on partial programs during generation. The core technical device is a sealor: a lightweight, mostly syntax-guided transformation that converts partial programs into complete ones that standard compilers can diagnose. It is designed such that possible-to-complete partial programs are never rejected, while preserving enough code context to catch genuine dead ends early. We construct such a sealor on a core Rust-like calculus and prove that it satisfies these properties, all mechanized in Lean. We extend it to the first partial-program checker for real Rust. We evaluate our method on challenging repository-level Rust coding tasks, across both frontier black-box and open-weight models. We show that generative compilation reduces non-compiling outputs and improves functional correctness, relative to standard post-generation feedback. It does so by detecting a broad range of errors close to their source and early during generation, thereby reducing errors cascades and enabling focused diagnostics. More broadly, generative compilation is a step toward making compilers a first-class citizen of AI-assisted programming active during generation, rather than a separate post-generation check.
Related papers
- Finding Compiler-Platform Interaction Bugs in Deep Learning Pipelines via Cross-Layer Constraints [6.16235197336957]
Testing deep learning (DL) compilers is challenging as correctness depends on implicit constraints embedded throughout the compilation stack.<n>Existing testing approaches largely take type constraints to restrict input model generation.<n>We propose a scalable, automated DL compiler testing framework for, in tandem, finding compiler-platform interaction bugs.
arXiv Detail & Related papers (2026-06-16T19:15:17Z) - Decaf: Improving Neural Decompilation with Automatic Feedback and Search [64.02615739798277]
High-level syntax, identifiers, and custom data types are generally lost as the compiler translates human-readable code to low-level machine code.<n>Generative AI models are a natural fit for reconstructing high-level syntax, identifiers, and types.<n>We argue that compiler feedback can be used to dramatically improve the semantic correctness of neural decompiler outputs via search.
arXiv Detail & Related papers (2026-05-12T04:21:26Z) - LLM4C2Rust: Large Language Models for Automated Memory-Safe Code Transpilation [1.4490522938516996]
Rust, one of the youngest modern programming languages, offers built-in memory-safety guarantees.<n>Transpiling C/C++ code into memory-safe Rust code has become a growing area of research.<n>We propose a Retrieval-Augmented Generation (RAG)-assisted framework to perform C/C++-to-Rust transpilation.
arXiv Detail & Related papers (2026-04-16T19:33:44Z) - Superset Decompilation [7.989066784325648]
decompilation is the reverse of compilation and can be structured as a sequence of modular passes.<n>We formalize this as provenance-guided superset decompilation (PGSD), a framework that monotonically derives facts about the binary into a relation store.<n>Mandel implements PGSD as a declarative reverse engineering framework that lifts Linux ELF binaries to C99 through a granular intermediate representation in 35K lines of Rust and Datalog.
arXiv Detail & Related papers (2026-03-30T03:47:19Z) - Context-Guided Decompilation: A Step Towards Re-executability [50.71992919223209]
Binary decompilation plays an important role in software security analysis, reverse engineering and malware understanding.<n>Recent advances in large language models (LLMs) have enabled neural decompilation, but the generated code is typically only semantically plausible.<n>We propose ICL4Decomp, a hybrid decompilation framework that leverages in-context learning (ICL) to guide LLMs toward generating re-executable source code.
arXiv Detail & Related papers (2025-11-03T17:21:39Z) - Type-Constrained Code Generation with Language Models [51.03439021895432]
We introduce a type-constrained decoding approach that leverages type systems to guide code generation.<n>For this purpose, we develop novel prefix automata and a search over inhabitable types, forming a sound approach to enforce well-typedness on LLM-generated code.<n>Our approach reduces compilation errors by more than half and significantly increases functional correctness in code synthesis, translation, and repair tasks.
arXiv Detail & Related papers (2025-04-12T15:03:00Z) - Context-aware Code Segmentation for C-to-Rust Translation using Large Language Models [1.8416014644193066]
Large language models (LLMs) show promise for automating this translation by generating more natural and safer code than rule-based methods.
We propose an LLM-based translation scheme that improves the success rate of translating large-scale C code into compilable Rust code.
In experiments with 20 benchmark C programs, including those exceeding 4 kilo lines of code, we successfully translated all programs into compilable Rust code.
arXiv Detail & Related papers (2024-09-16T17:52:36Z) - Decoding at the Speed of Thought: Harnessing Parallel Decoding of Lexical Units for LLMs [57.27982780697922]
Large language models have demonstrated exceptional capability in natural language understanding and generation.
However, their generation speed is limited by the inherently sequential nature of their decoding process.
This paper introduces Lexical Unit Decoding, a novel decoding methodology implemented in a data-driven manner.
arXiv Detail & Related papers (2024-05-24T04:35:13Z) - Outline, Then Details: Syntactically Guided Coarse-To-Fine Code
Generation [61.50286000143233]
ChainCoder is a program synthesis language model that generates Python code progressively.
A tailored transformer architecture is leveraged to jointly encode the natural language descriptions and syntactically aligned I/O data samples.
arXiv Detail & Related papers (2023-04-28T01:47:09Z)
This list is automatically generated from the titles and abstracts of the papers in this site.
This site does not guarantee the quality of this site (including all information) and is not responsible for any consequences.