non-SSA IR generation

I am experimenting with LLVM optimizer and found that the bit code file clang emits is already in SSA form, but I want to generate it in non-SSA form. Would you let me know if there is any way of doing it?

Cheera,
Amruth

Hi Amruth,

If you do not specify any optimization flag for ‘clang’ and do not run ‘opt -mem2reg’ pass on the generated IR file, it is in non-SSA form. However, many variables stay in memory instead of registers in this case.

Thanks,
Jiesheng

Hi Jiesheng,

I did try that. Below is the command I used to generate the bit code file using clang.

clang -emit-llvm sample.cpp -S -o sample.ll

I am not sure if I need to take out -emit-llvm option too.
The resulting bit code file had instances with variables being assigned only once though it did not contain any phi nodes. My understanding is that code could be in SSA form even without having phi nodes. I am not running any opt modules on the code.

Please correct me if I am wrong.

Cheers,
Amruth

Well, it is in SSA form, but it “cheats” by keeping values in memory.

–Sean Silva

I think Sean is right. If you want “real” SSA form, my sense is that you may need to write your own passes and module verifier.

Thanks,
Jiesheng