unoptimised LLVM, not in SSA form

Hi,

I am interested in obtaining LLVM IR without any optimization performed on
it.( IR obtained from cfrontend's AST). Is this LLVM IR in SSA form?

Secondly, I want to make a transformation on this unoptimized IR, and convert
it back to C. I believe llc -c does that.

Thirdly, is it possible to use LLVM tool suite on LLVM IR that's not in SSA
form, if we have such LLVM so.

I am interested in obtaining LLVM IR without any optimization performed on
it.( IR obtained from cfrontend's AST). Is this LLVM IR in SSA form?

You can do this, using "llvm-gcc -S". The ".s" file it produces is an entirely unoptimized llvm file. Note that this is not really suitable to source-to-source level transformations, but should have most of the information from the source. If you add -g, you'll even get line number info.

Secondly, I want to make a transformation on this unoptimized IR, and convert
it back to C. I believe llc -c does that.

Yup, llc -march=c

Thirdly, is it possible to use LLVM tool suite on LLVM IR that's not in SSA
form, if we have such LLVM so.

No, LLVM IR is always in SSA form. If PHI nodes specifically are a problem for you, there are ways to produce LLVM code without any PHI nodes (e.g. create allocas and do load/stores into them).

-Chris

I am interested in obtaining LLVM IR without any optimization performed on
it.( IR obtained from cfrontend's AST). Is this LLVM IR in SSA form?

All LLVM is in SSA form. However, the cfrontend uses allocs and
explicit loads and stores so it doesn't have to worry about this. The
pass mem2reg converts the code with memory locations for each variable
into code with variables in virtual registers that are in SSA form.

use
llvm-gcc -Wa,-disable-opt -Wl,-disable-opt
to have llvm-gcc skip all optimizations. This is very very ugly code.
You can then run optimization by hand using opt. See the web pages for
more information there.

Secondly, I want to make a transformation on this unoptimized IR, and convert
it back to C. I believe llc -c does that.

llc -march=c does that.

Thirdly, is it possible to use LLVM tool suite on LLVM IR that's not in SSA
form, if we have such LLVM so.

LLVM IR is defined as being in SSA form. It will not verify if it is
not.

Andrew

This question has become a FAQ:
http://llvm.cs.uiuc.edu/docs/FAQ.html#cfe