I am familiar with the LLVM IR a little bit and I am parsing much more complex examples. I just gave this example, to show that I would like to have only 1 variable, not 2, the way SSA would generate it. I am actually using LLVM purely as a front end to translate to .bc files and then I have my own parser from there. At any rate, is there an option to the llvm-gcc --emit-llvm to tell it to produce .bc files that are at least space optimized (or even better, not in SSA form) ? thanks Óscar Fuentes wrote:> > ivtm <martinaide1 at yahoo.com> writes: > >> I am wondering if there are options that can be given to LLVM can be used >> to >> generate code that is not in SSA, but in plain 3-address form ? (for >> example, if there is an existing pass that does the register allocation >> and >> dead variable elimination) >> >> For example, if I have: >> >> int x = 0; >> >> void main() >> { >> x++; >> x++; >> } >> >> I guess, if that is not the case, then, one needs to write their own >> pass. > > Why do you want to avoid SSA? > > SSA on LLVM is much simpler than it seems, the API makes generating SSA > natural, almost not noticing it. Your above example is trivial. Go to > http://www.llvm.org/demo and see how your C/C++ code is translated to > LLVM IR (pay attention to the options available on the web form). > > And of course there are passes for register allocation, dead variable > elimination and more. > > [snip] > > -- > Óscar > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- View this message in context: http://www.nabble.com/LLVM-SSA-tp25621668p25625857.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
> At any rate, is there an option to the llvm-gcc --emit-llvm to tell it to > produce .bc files that are at least space optimized (or even better, not in > SSA form) ?Yes, -O0 -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
ivtm <martinaide1 at yahoo.com> writes:> I am familiar with the LLVM IR a little bit and I am parsing much more > complex examples. I just gave this example, to show that I would like to > have only 1 variable, not 2, the way SSA would generate it. > I am actually using LLVM purely as a front end to translate to .bc files and > then I have my own parser from there. > > At any rate, is there an option to the llvm-gcc --emit-llvm to tell it to > produce .bc files that are at least space optimized (or even better, not in > SSA form) ?You could simulate a Load/Store architecture by mapping each variable to an AllocaInst (which is what all compilers do, I guess). Then in your passes track accesses to those allocas. -- Óscar
I tried the -O0 option and I am still getting output in SSA form: I do: llvm-gcc -O0 -emit-llvm -c x.c -o x.bc, and then: llvm-dis x.bc Anton Korobeynikov-2 wrote:> >> At any rate, is there an option to the llvm-gcc --emit-llvm to tell it to >> produce .bc files that are at least space optimized (or even better, not >> in >> SSA form) ? > Yes, -O0 > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- View this message in context: http://www.nabble.com/LLVM-SSA-tp25621668p25628356.html Sent from the LLVM - Dev mailing list archive at Nabble.com.