[LLVMdev] redefenition of variables in LLVM
Chris Lattner
sabre at nondot.org
Sun Dec 12 00:13:15 PST 2004
On Sun, 12 Dec 2004, 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 !
> :)
No, this is Static Single Assignment form, which means there can only be
one assignment to a value. If you want multiple assignment, use memory
(such as a stack location). E.g.:
%t4 = alloca int
%_t4 = add int 23 , 0
store int %_t4, int* %t4
%_t5 = add int %_t4 , 1
%_t4 = add int %_t5 , 0
store int %_t4, int* %t4
Given (ugly) code like this, the LLVM -mem2reg pass will construct SSA for
you and discard the unneeded allocas.
-Chris
--
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/
More information about the llvm-dev
mailing list