[LLVMdev] redefenition of variables in LLVM

Vikram Adve vadve at cs.uiuc.edu
Sun Dec 12 04:28:27 PST 2004


Jai,

Just to add a bit of context to Chris's reply ...

As he pointed out, LLVM registers are in SSA form but memory is not.  
You do not need to generate SSA form when generating LLVM in your 
front-end, because it is not straightforward to do so.  Instead, you 
can "alloca" all variables on the stack, and use loads and stores to 
access their values.  mem2reg will promote most such alloca variables 
back to registers in SSA form.

If you want to generate more compact code, you can put local 
temporaries (from within a simple source statement) in SSA registers 
since they are not used outside the basic block where they are 
generated.  For example, you could put %_t5 in a register below easily, 
but leave _t4 on the stack.  This is not particularly important for 
small programs.

On Dec 12, 2004, at 1:14 AM, Jai Vasanth wrote:

> Hi,
>
>
> %_t4 = add int 23 ,  0
> %_t5 = add int %_t4 , 1
> %_t4 = add int %_t5 , 0
>
> the above line of code give an error when i try to  convert to
> bytecode. The error is that I am trying to redefine %_t4. Is there a
> way to reassign a variable with another value. Also is there a way to
> assign a value to a variable. I couldnt do that so I added 0 to it  !
> :)
>
> Thanks
>
>
> Jai
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
>

--Vikram
http://www.cs.uiuc.edu/~vadve
http://llvm.cs.uiuc.edu/




More information about the llvm-dev mailing list