[LLVMdev] How to eliminate PHI nodes on pointer types?

Andrew Clinton andrew at sidefx.com
Mon Aug 20 13:39:43 PDT 2012


On 08/20/2012 03:46 PM, Duncan Sands wrote:
> Hi Andrew,
>
>> Somewhere during optimization PHI nodes on pointer types (including
>> alloca instructions) are being introduced, and they persist through the
>> scalar replacement of aggregates pass and others.  I can't seem to find
>> a combination of passes or transformations to get rid of them.  Has
>> anyone had this problem before, and know a transformation to eliminate
>> it?  My optimization passes rely on everything being in pure SSA form.
> why is this a problem?  Presumably you are happy with phi nodes of integer
> or float type, why are phi nodes of pointer type problematic?
>
> Ciao, Duncan.
>
> PS: I'm not sure what you mean by "pure SSA form".  Phi nodes are needed for
> values of pointer type exactly because these values are in SSA form...

By "pure" I mean that the IR has no alloca instructions, ie. it all has 
been promoted to registers.  It's easy to see that this is possible in 
the program I posted (by changing the PHI to one on loaded values rather 
than pointers).  The presence of allocas is problematic since the 
analysis and lowering passes in my optimizer don't handle them.

Andrew



More information about the llvm-dev mailing list