[LLVMdev] Re: how to code a loop in llvm assembly

Patrick Meredith pmeredit at uiuc.edu
Sat Apr 15 12:40:25 PDT 2006

On Apr 15, 2006, at 2:24 PM, Reid Spencer wrote:

> FYI, in case you're wondering about the validity of this approach,
> generating alloca instructions and relying on -mem2reg is what the  
> C/C++
> front ends do. It is a little more straight forward to code than
> manually worrying about the PHI nodes.

Yeah I wouldn't want to worry about calculating dominance frontiers  
in my
code generator unless I had to :)

> Either approach will work, take
> your pick :)
> Reid.
> On Sat, 2006-04-15 at 09:13 -0500, Misha Brukman wrote:
>> As others have pointed out, because LLVM is in SSA form, you will  
>> need
>> to use a phi node.  To see how it would be written, try using the  
>> demo
>> script as Oscar suggested, or you can do what you suggested (I  
>> would use
>> alloca instead of malloc, though I think either should work) and then
>> run it through "opt -mem2reg" to convert it to the phi-node form.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

More information about the llvm-dev mailing list