[llvm-commits] [Review request] New StrongPHIElimination implementation

Evan Cheng evan.cheng at apple.com
Tue Oct 5 21:57:39 PDT 2010


Looks pretty awesome on first glance. We'll review this as soon as possible. Thanks. 

Evan

On Oct 5, 2010, at 3:23 PM, Cameron Zwarich <zwarich at apple.com> wrote:

> I've been wanting to implement SSA-based register allocation in LLVM, but since that is a bit of a major task, I wanted to do something smaller to get myself more familiar with the backend. I decided to rewrite the StrongPHIElimination pass and get it closer to working. I split the pass up into 3 stages:
> 
> 1) AggressivePHICoalescing - this computes an aggressive coalescing of virtual registers that appear as operands or destinations of phis. It doesn't actually perform any coalescing, but it provides a data structure that later passes can query. This makes the code more modular, with no real change in performance, and it also means that the coalescing can be used for other purposes like SSA register allocation.
> 
> The implementation here is much slicker than the original, because it does away with the dominance forests entirely and performs all of the interference tests in a single depth-irst walk of the dominator tree. Phis are also modeled a bit differently, which makes it possible for StrongPHIElimination to work with critical edges.
> 
> 2) CSSA - this pass converts the program into Conventional SSA form by inserting copies based on the results of AggressivePHICoalescing. Conventional SSA is SSA with the restriction that phi-congruent variables do not have overlapping live ranges.
> 
> 3) StrongPHIElimination - since the program is now in CSSA form, StrongPHIElimination just renames phi-congruent registers, merges their live ranges, and deletes the phis.
> 
> Some comments on my patch:
> 
> 1) While the pass at least completes on the simple examples I tried (unlike the existing code), it causes SimpleRegisterCoalescing to hit an assertion failure. I am not certain whether this is due to a bug in the way the new code updates LiveIntervals or a bad assumption in SimpleRegisterCoalescing that is satisfied by PHIElimination but not StrongPHIElimination.
> 
> 2) I had to copy two functions from PHIElimination, SkipPHIsAndLabels() and FindCopyInsertPoint(). Presumedly, these should go somewhere shared, but where?
> 
> 3) It handles critical edges, but it still might be better to split them sometimes.
> 
> I've attached both a diff and a copy of the StrongPHIElimination.cpp file (as it got mangled pretty bad by the diff).
> 
> Cameron
> 
> <strong-phi.patch>
> <StrongPHIElimination.cpp>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list