[LLVMdev] CFG using LLVM
Nick Lewycky
nicholas at mxc.ca
Sat Nov 14 09:54:26 PST 2009
Hersh.S. Iyer wrote:
> Hi,
>
> I am a new user of LLVM. I am using it as the IR for a compiler for a
> subset of LUA.
> I have the .ll file ready and it executes fine when passed to the llvm
> interpreter.
>
> Now, I wish to perform a few optimizations to the code starting with
> dead code elimination.
> For this I would need the CFG. I am very new to all of this stuff.
> Please help me out guys.
> The way I want to proceed is to start at the top of the CFG and then
> find out the blocks
> reachable from here. At the end, if any basic block remains unreachable,
> then I would
> classify it as dead code.
>
> I read a few things about llvm passes and felt this could be made a
> pass. Please let me
> know what's the right and fastest way to do this.
If what's you've got is a .ll file on disk and you're just wondering how
to optimize it, use the 'opt' tool. The list of passes available in LLVM
is here: http://llvm.org/docs/Passes.html .
A good default selection is available through 'opt -std-compile-opts',
and if your .ll file represents a whole program (ie., it includes
main()) then you can run 'opt -std-link-opts' too.
Nick
More information about the llvm-dev
mailing list