Review on existing open-source Register Allocation algorithms with GCC\LLVM

The essence of compiler is in back-end, precisely, it is optimization. And Register Allocation is one very important aspect of compiler optimization. 

This article contains a simple review on existing open sourced Register Allocation algorithms, with GCC and LLVM.

1. Traditional, general Register Allocation algorithm - Graph Coloring

In input language, there exists an invisible reference\dependent graph among registers and instructions. To avoid conflictions, different vars should reside in different registers. Essentially it is a graph coloring algorithm, which is a NP-hard problem. This is not the focus of this review. Please refer to http://www.cs.cmu.edu/~dkoes/research/graphraTR.pdf


2. GCC vs. LLVM

GCC buys the graph coloring algorithm, but it seems not easy to do this job: http://gcc.gnu.org/wiki/RegisterAllocation. But LLVM decides to adopt simpler but more efficient methods to implement RA problem: linear scanning + spiller strategy, and it says it works very well, with 1-2% smaller memory occupation and up to 10% faster code execution. And in LLVM, Greedy RA algorithm is defaulted, which is based on the linear scanning strategy, in which reg life intervals are basic tools to operate.


In perspective of engineering, it is LLVM that is a better choice indeed - simpler, more capable. http://blog.llvm.org/2011/09/greedy-register-allocation-in-llvm-30.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值