MLGO: a Machine Learning Guided Compiler Optimizations Framework
Mircea Trofin (1), Yundi Qian (1), Eugene Brevdo (1), Zinan Lin (2),, Krzysztof Choromanski (1), David Li (1) ((1) Google, Inc., (2) Carnegie, Mellon University)

TL;DR
MLGO introduces a systematic framework for integrating machine learning into industrial compilers, demonstrated by replacing heuristics with learned models in LLVM, achieving size reductions and good generalization in real-world scenarios.
Contribution
This work presents the first full integration of machine learning techniques into a complex, real-world compiler pass, specifically LLVM's inlining optimization.
Findings
Achieved up to 7% size reduction compared to LLVM -Oz.
Models trained on one corpus generalize well to diverse real-world targets.
Demonstrated successful integration of ML techniques in an industrial compiler setting.
Abstract
Leveraging machine-learning (ML) techniques for compiler optimizations has been widely studied and explored in academia. However, the adoption of ML in general-purpose, industry strength compilers has yet to happen. We propose MLGO, a framework for integrating ML techniques systematically in an industrial compiler -- LLVM. As a case study, we present the details and results of replacing the heuristics-based inlining-for-size optimization in LLVM with machine learned models. To the best of our knowledge, this work is the first full integration of ML in a complex compiler pass in a real-world setting. It is available in the main LLVM repository. We use two different ML algorithms: Policy Gradient and Evolution Strategies, to train the inlining-for-size model, and achieve up to 7\% size reduction, when compared to state of the art LLVM -Oz. The same model, trained on one corpus,…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsMachine Learning and Data Classification · Parallel Computing and Optimization Techniques · Reinforcement Learning in Robotics
