当前位置: X-MOL 学术arXiv.cs.PL › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
Efficient global register allocation
arXiv - CS - Programming Languages Pub Date : 2020-11-11 , DOI: arxiv-2011.05608
Ian Rogers

In a compiler, an essential component is the register allocator. Two main algorithms have dominated implementations, graph coloring and linear scan, differing in how live values are modeled. Graph coloring uses an edge in an `interference graph' to show that two values cannot reside in the same register. Linear scan numbers all values, creates intervals between definition and uses, and then intervals that do not overlap may be allocated to the same register. For both algorithms the liveness models are computed at considerable runtime and memory cost. Furthermore, these algorithms do little to improve code quality, where the target architecture and register coalescing are important concerns. We describe a new register allocation algorithm with lightweight implementation characteristics. The algorithm introduces a `future-active' set for values that will reside in a register later in the allocation. Registers are allocated and freed in the manner of linear scan, although other ordering heuristics could improve code quality or lower runtime cost. An advantageous property of the approach is an ability to make these trade-offs. A key result is the `future-active' set can remove any liveness model for over 90% of instructions and 80% of methods. The major contribution is the allocation algorithm that, for example, solves an inability of the similarly motivated Treescan register allocator to look ahead of the instruction being allocated - allowing an unconstrained allocation order, and an ability to better handle fixed registers and loop carried values. The approach also is not reliant on properties of SSA form, similar to the original linear scan work. An analysis is presented in a production compiler for Java code compiled through SSA form to Android dex files.

中文翻译:

高效的全局寄存器分配

在编译器中,一个必不可少的组件是寄存器分配器。两种主要算法主导了实现,图形着色和线性扫描,它们在建模实时值的方式上有所不同。图着色使用“干涉图”中的边来表明两个值不能驻留在同一个寄存器中。线性扫描编号所有值,在定义和使用之间创建间隔,然后不重叠的间隔可以分配给同一个寄存器。对于这两种算法,活性模型的计算都需要相当大的运行时间和内存成本。此外,这些算法对提高代码质量几乎没有作用,其中目标架构和寄存器合并是重要的问题。我们描述了一种具有轻量级实现特性的新寄存器分配算法。该算法引入了“未来活跃” 为稍后分配的寄存器中的值设置。寄存器以线性扫描的方式分配和释放,尽管其他排序启发式可以提高代码质量或降低运行时成本。该方法的一个有利特性是能够进行这些权衡。一个关键结果是“未来活动”集可以删除超过 90% 的指令和 80% 的方法的任何活性模型。主要贡献是分配算法,例如,它解决了具有类似动机的 Treescan 寄存器分配器无法提前分配指令的问题——允许无约束的分配顺序,以及更好地处理固定寄存器和循环携带值的能力。该方法也不依赖于 SSA 形式的属性,类似于原始线性扫描工作。
更新日期:2020-11-12
down
wechat
bug