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. Also, what call an inbuilt pass from my own pass after doing some analysis. Thank you & regards, Chayan On Tue, Jun 1, 2010 at 10:59 PM, Ander Martinez <dwarfnauko at gmail.com> wrote:> You can use STOREs and LOADs on memory and then use mem2reg pass. > > 2010/6/1 Chayan Sarkar <chayan.ju at gmail.com>: >> Hi, >> >> Can anyone tell me, whether it is possible to convert a program into >> SSA form without considering algebric equivalence ? >> >> regards, >> Chayan >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >
Hello Chayan- I think you might find Kaleidoscope tutorial (http://llvm.org/docs/tutorial/), particularly the section on mutable variables and SSA construction (http://llvm.org/docs/tutorial/LangImpl7.html), useful here. Alistair On 5 Jun 2010, at 10:03, Chayan Sarkar 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. > > Also, what call an inbuilt pass from my own pass after doing some analysis. > > Thank you & regards, > Chayan > > On Tue, Jun 1, 2010 at 10:59 PM, Ander Martinez <dwarfnauko at gmail.com> wrote: >> You can use STOREs and LOADs on memory and then use mem2reg pass. >> >> 2010/6/1 Chayan Sarkar <chayan.ju at gmail.com>: >>> Hi, >>> >>> Can anyone tell me, whether it is possible to convert a program into >>> SSA form without considering algebric equivalence ? >>> >>> regards, >>> Chayan >>> _______________________________________________ >>> LLVM Developers mailing list >>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >>> >> > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
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
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 >