Compiler optimization passes are an important tool for improving program efficiency and reducing program size, but manually selecting optimization passes can be time-consuming and error-prone. While human experts have identified a few fixed sequences of optimization passes (e.g., the Clang -Oz passes) that perform well for a wide variety of programs, these sequences are not conditioned on specific programs. In this paper, we propose a novel approach that learns a policy to select passes for program size reduction, allowing for customization and adaptation to specific programs. Our approach uses a search mechanism that helps identify useful pass sequences and a GNN with customized attention that selects the optimal sequence to use. Crucially it is able to generalize to new, unseen programs, making it more flexible and general than previous approaches. We evaluate our approach on a range of programs and show that it leads to size reduction compared to traditional optimization techniques. Our results demonstrate the potential of a single policy that is able to optimize many programs.
翻译:编译器优化通行证是提高程序效率和减少程序规模的重要工具, 但人工选择优化通行证可以耗费时间和容易出错。 虽然人类专家已经确定了对多种程序效果良好的一些固定的优化通行证序列( 如Clang-Oz通行证), 这些序列并不以具体程序为条件。 在本文中, 我们提出了一个新颖的方法, 来学习如何选择降低程序规模的通行证, 允许对特定程序进行定制和调整。 我们的方法使用一种搜索机制, 帮助识别有用的通行证序列, 以及一个具有特定关注选择最佳使用顺序的GNN。 关键是, 它能够对新的、 看不见的程序进行概括化, 使其更加灵活和一般化。 我们评估了我们对于一系列程序的做法, 并表明它比传统的优化技术导致规模缩小。 我们的结果显示了一种能够优化许多程序的单一政策的潜力 。