[LLVMdev] Converting into SSA form

Chayan Sarkar chayan.ju at gmail.com
Sat Jun 5 05:53:16 PDT 2010


Suppose my Input function is like :

myfunc(int x,int y){
    int a=2, b=3,c=5;
    if(x>y) {
        c=a+b;
        a=6;
    }
    else {
        c=a*b;
        b=4;
    }
    a=c+a;
    c=a+b;
}

and the output should be :

myfunc(int x,int y){
    int a.0=2, b.0=3,c.0=5;
    if(x>y) {
        c.1=a.0+b.0;
        a.1=6;
    }
    else {
        c.2=a.0*b.0;
        b.1=4;
    }
    a.2=phi(a.1,a.0);
    b.2=phi(b.0,b.1);
    c.3=phi(c.1,c.2);
    a.3=c.3+a.2;
    c.4=a.3+b.2;
}


Thank you for your response.


On Sat, Jun 5, 2010 at 3:03 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Sat, Jun 5, 2010 at 2:03 AM, Chayan Sarkar <chayan.ju at gmail.com> wrote:
>> But, the mem2reg pass removes all load store instructions. It replaces
>> all variables by their if possible (kind of constant propagation). I
>> have generated the bitcode of the source program and the applied the
>> mem2reg pass and obviously not getting desired thing.
>>
>> What I want is convert it into SSA form without replacing any variable
>> by their constant value. Please elaborate on your point.
>
> Can you give a short sample program and what you expect the output to look like?
>
> -Eli
>



More information about the llvm-dev mailing list