Abstract
Compiler pass auto-tuning is critical for enhancing software performance, yet finding the optimal pass sequence for a specific program is an NP-hard problem. Traditional, general-purpose optimization flags like -O3 and -Oz adopt a one-size-fits-all approach, often failing to unlock a program's full performance potential. To address this challenge, we propose a novel Hybrid, Knowledge-Guided Evolutionary Framework. This framework intelligently guides online, personalized optimization using knowledge extracted from a large-scale offline analysis phase. During the offline stage, we construct a comprehensive compilation knowledge base composed of four key components: (1) Pass Behavioral Vectors to quantitatively capture the effectiveness of each optimization; (2) Pass Groups derived from clustering these vectors based on behavior similarity; (3) a Synergy Pass Graph to model beneficial sequential interactions; and (4) a library of Prototype Pass Sequences evolved for distinct program types. In the online stage, a bespoke genetic algorithm leverages this rich knowledge base through specially designed, knowledge-infused genetic operators. These operators transform the search by performing semantically-aware recombination and targeted, restorative mutations. On a suite of seven public datasets, our framework achieves an average of 11.0% additional LLVM IR instruction reduction over the highly-optimized opt -Oz baseline, demonstrating its state-of-the-art capability in discovering personalized, high-performance optimization sequences.
Introduction
Modern compilers like LLVM are packed with hundreds of optimization passes designed to clean up or shrink code. However, the order in which these passes are applied—the "phase-ordering problem"—is a combinatorial nightmare. Standard static flags like -Oz are "one-size-fits-all" and often leave significant performance on the table. While iterative compilation can find better results, it typically takes hours, making it impractical for standard developer workflows.
This paper presents a hybrid framework that moves the heavy computational lifting of mining pass interactions to a one-time offline phase, enabling fast, high-quality online tuning in approximately 10 seconds per program.
Methodology
The framework splits the optimization process into two stages: offline knowledge building and online personalized tuning.
Offline Knowledge Extraction
By analyzing nearly 20,000 programs, the framework builds a Pass Knowledge Base. A core component of this base is the Pass Behavioral Vector, which quantitatively captures how each pass performs across different program types.
As illustrated in the distribution above, passes like sroa and gvn show high variance and significant potential for instruction reduction, while others may occasionally increase code size. Modeling these "personalities" allows the framework to avoid the "black box" limitations of standard machine learning approaches.
Online Knowledge-Guided Evolution
The online stage uses a Genetic Algorithm (GA) that is "knowledge-infused." Instead of random search, it utilizes:
- Smart Initialization: Seeding the population with "Prototype Sequences" known to work for similar programs.
- Knowledge-Guided Crossover: Swapping functional blocks of passes to maintain semantic logic.
- Restorative Mutation: Identifying weak links in a sequence and using the Synergy Graph to find statistically likely repairs.
Evaluation and Results
The framework was tested on 335 unseen programs across seven diverse benchmarks, including mibench, opencv, and tensorflow.
- Code Size Reduction: Achieved an average 11.0% additional reduction in LLVM IR instructions over the
opt -Ozbaseline. - Competitive Advantage: Outperformed state-of-the-art methods such as
CFSAT(9.13%) and the Large Language Model-basedCompiler-R1(8.46%). - Practicality: The system converges in an average of 10 seconds, providing a significant speed advantage over traditional iterative methods.
Conclusion
By explicitly modeling pass relationships and behaviors, the proposed hybrid framework provides a fast and effective solution to the phase-ordering problem. Future work will focus on multi-objective tuning to simultaneously optimize for execution speed and power consumption alongside code size.
Summary updated