NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

AwareCompiler: Agentic Context-Aware Compiler Optimization via a Synergistic Knowledge-Data Driven Framework

Hongyu Lin, Haolin Pan, Haoran Luo, Yuchen Li, Kaichun Yao, Libo Zhang, Mingjie Xing, Yanjun Wu · DOI

Abstract

AwareCompiler is an agentic framework designed to master the complex task of compiler optimization by integrating structured domain knowledge with reinforcement learning. Traditional compiler heuristics often fail to find optimal pass sequences for specific codebases, while general-purpose Large Language Models (LLMs) suffer from semantic misalignment and inefficient search strategies. AwareCompiler bridges this gap using a synergistic knowledge-data driven architecture that includes a symbolic knowledge base and an adaptive reasoning mechanism. Experimental results demonstrate that AwareCompiler achieves an average code size reduction of approximately 30%, significantly outperforming both traditional heuristics and state-of-the-art models like GPT-5 and DeepSeek-V3 while maintaining a near 100% success rate in generating valid pass sequences.

Introduction

Modern software development relies heavily on compilers to transform high-level source code into efficient machine instructions. A critical part of this process is the selection and ordering of "optimization passes." However, the search space for these sequences is astronomically large, making the identification of the perfect order for a specific program a "black art."

Historically, compilers have relied on fixed heuristics like -O3 or -Oz. While reliable, these "one-size-fits-all" approaches often miss significant optimization opportunities. Recent attempts to use Machine Learning (ML) and LLMs have shown promise but face significant hurdles, including semantic misalignment (where model suggestions do not match code structure), inefficient trial-and-error interactions, and the challenge of reward sparsity in long pass sequences.

Comparison of compiler optimization paradigms, highlighting the evolution from heuristics to the AwareCompiler approach.

The AwareCompiler Framework

To overcome the limitations of existing methods, the authors propose AwareCompiler. This framework shifts from a purely data-driven or heuristic-based approach to a "synergistic knowledge-data driven" model.

Architecture and Pillars

The architecture of AwareCompiler is built upon three fundamental pillars:

  1. Structured Knowledge Integration: The system utilizes a symbolic knowledge base that categorizes information into three streams: empirical data (historical successes), symbolic rules (formal pass dependencies), and negative knowledge (sequences to avoid due to regressions or crashes).
  2. Knowledge-Driven Adaptive Pass Generation: The agent does not generate sequences in a vacuum. It first extracts 56 statistical features from the source code using tools like AutoPhase. It then performs a retrieval step from its knowledge base to "reason" through a strategy before committing to a final pass sequence.
  3. Hybrid Training Pipeline: The model is refined through a two-stage process. Supervised Fine-Tuning (SFT) establishes a baseline for reasoning and heuristic application, followed by Reinforcement Learning (RL) that uses a composite reward function to prioritize valid, effective code size reduction.
Detailed view of the AwareCompiler agentic workflow, showing the interaction between the agent, knowledge base, and the compilation process.

Experimental Evaluation

AwareCompiler was tested against a wide array of standard compiler benchmarks, including scientific computing (blas, npb), general-purpose utilities (cbench, mibench), and domain-specific libraries like tensorflow and opencv.

Key Results

  • Optimization Efficiency: AwareCompiler achieved an average code size reduction of ~30%, matching or exceeding the performance of the expert-tuned -Oz heuristic.
  • Comparison with LLMs: The framework significantly outperformed general-purpose models. While AwareCompiler reached ~30% reduction, GPT-5 achieved only ~12.9% and DeepSeek-V3 reached ~26.5%.
  • Robustness: One of the most significant advantages was reliability. AwareCompiler maintained a near 100% success rate in generating valid, compilable pass sequences, whereas vanilla LLMs frequently suggested "illegal" combinations that led to compiler crashes.

Discussion and Insights

A core finding of this research is the utility of "Negative Knowledge." By explicitly training the agent on what not to do, the researchers drastically reduced the frequency of "hallucinated" strategies. Furthermore, the use of reasoning as a bridge—forcing the model to analyze code features before acting—successfully mitigated semantic misalignment.

Interestingly, the study found that smaller, specialized models (1.5B to 7B parameters) equipped with this agentic framework could outperform massive general-purpose models. This suggests that for specialized engineering tasks like compiler optimization, domain-specific tuning and structured reasoning are more impactful than raw parameter count.

Conclusion and Future Work

AwareCompiler represents a significant step forward in automating compiler optimization. By combining the reasoning capabilities of LLMs with the rigor of symbolic knowledge, it provides a robust and effective solution for code size reduction. Future work will look to expand the framework's objectives to include execution latency and energy efficiency, as well as broadening its application beyond the LLVM ecosystem.

Summary updated

BibTeX
@misc{lin2025awarecompiler,
  author = {Hongyu Lin and Haolin Pan and Haoran Luo and Yuchen Li and Kaichun Yao and Libo Zhang and Mingjie Xing and Yanjun Wu},
  title = {{AwareCompiler: Agentic Context-Aware Compiler Optimization via a Synergistic Knowledge-Data Driven Framework}},
  year = {2025},
  eprint = {2510.11759},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.11759},
}
Figure