[LLVMdev] IR in SSA form?

George Baah georgebaah at gmail.com
Tue Mar 29 12:19:23 PDT 2011


Oh I see. Thanks!

On Tue, Mar 29, 2011 at 1:37 PM, John Criswell <criswell at cs.uiuc.edu> wrote:

> On 3/29/11 12:26 PM, George Baah wrote:
>
>> Hi All,
>>  When I run the following command
>> llvm-gcc -03 -emit-llvm test.cpp -c -o test.bc or llvm-gcc -emit-llvm
>> test.cpp -c -o test.bc
>>
>> on the program test.cpp, the IR representation is not in SSA form.
>> I do not see any phi functions.
>>
>
> Actually, it is in SSA form (or more precisely, the virtual registers are
> in SSA form; LLVM only puts virtual registers into SSA form).  However, all
> program variables are code-generated to alloca instructions and then
> accessed using load and store instructions.
>
> To lift stack-allocated variables into virtual registers (essentially
> putting them into SSA form), run the mem2reg pass (opt -mem2reg test.bc -f
> -o test.opt.bc).  This will take non-address taken alloca's, convert them
> into virtual registers, and introduce phi-nodes where needed.
>
> -- John T.
>
>
>
>> program: test.cpp
>> int main(int argc, char **argv)
>> {
>>  int a[2],i,j;
>>  for(i=0;i<2;i++)
>>  {
>>    a[i] = i;
>>  }
>>  return a[1];
>> }
>>
>> Any clarifications will be greatly appreciated. Thanks.
>>
>> George
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110329/d0fd4e45/attachment.html>


More information about the llvm-dev mailing list