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.
On Sat, 27 Aug 2005, Umar Janjua wrote:> 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 -- http://nondot.org/sabre/ http://llvm.org/
On Sat, 2005-08-27 at 13:18 +0100, Umar Janjua wrote:> 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
On Sat, Aug 27, 2005 at 01:18:56PM +0100, Umar Janjua wrote:> 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?This question has become a FAQ: http://llvm.cs.uiuc.edu/docs/FAQ.html#cfe -- Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu
Hi, The getCalledFunction on CallInst is returning NULL, although it is (directly) calling a function, which is defined in the same file. ---------------------- if (CallInst* callInst = dyn_cast<CallInst>(&inst)) { std::cerr<<callInst->getCalledFunction(); } ----------------------- When ------------------ std::cerr<<*callInst ---------------- the output is. %tmp.10 = call int (...)* cast (int ()* %releaseLock to int (...)*)( ) ; <int> [#uses=0] Note: releaseLock is defined in the same file and is not called as function pointer. Do I require some other pass information beforehand.