Modern compilers rely on hand-crafted heuristics to guide optimization passes. These human-designed rules often struggle to adapt to the complexity of modern software and hardware and lead to high maintenance burden. To address this challenge, we present Magellan, an agentic framework that evolves the compiler pass itself by synthesizing executable C++ decision logic. Magellan couples an LLM coding agent with evolutionary search and autotuning in a closed loop of generation, evaluation on user-provided macro-benchmarks, and refinement, producing compact heuristics that integrate directly into existing compilers. Across several production optimization tasks, Magellan discovers policies that match or surpass expert baselines. In LLVM function inlining, Magellan synthesizes new heuristics that outperform decades of manual engineering for both binary-size reduction and end-to-end performance. In register allocation, it learns a concise priority rule for live-range processing that matches intricate human-designed policies on a large-scale workload. We also report preliminary results on XLA problems, demonstrating portability beyond LLVM with reduced engineering effort.
翻译:现代编译器依赖手工设计的启发式规则来指导优化过程。这些人为设计的规则往往难以适应现代软硬件的复杂性,并导致高昂的维护负担。为应对这一挑战,我们提出麦哲伦——一个通过合成可执行的C++决策逻辑来进化编译器过程本身的智能体框架。麦哲伦将LLM代码生成智能体与进化搜索及自动调优相结合,形成生成、在用户提供的宏观基准测试上评估、优化的闭环流程,从而产生可直接集成到现有编译器中的紧凑启发式规则。在多项实际优化任务中,麦哲伦发现的策略均达到或超越了专家基线水平。在LLVM函数内联优化中,麦哲伦合成的新启发式规则在二进制大小缩减和端到端性能方面均优于数十年人工工程积累的成果。在寄存器分配任务中,它学习到一条简洁的活跃区间处理优先级规则,在大规模工作负载上达到了复杂人工设计策略的同等效果。我们还报告了在XLA问题上的初步实验结果,展示了该框架在LLVM之外的可移植性及较低的工程开销。