[LLVMdev] Runtime optimization using llvm
Dmitry N. Mikushin
maemarcus at gmail.com
Mon Oct 31 14:42:36 CDT 2011
Passes in LLVM are performed on LLVM intermediate representation (IR)
level. Thus, your original C program should be first translated to IR
using one of available frontends. Next, if you work with LLVM at code
level, module class has method dump(), that could print its current
// Wrap memory buffer around string containing *input* module source.
MemoryBuffer* buffer2 = MemoryBuffer::getMemBuffer(out);
// Load Module m2 from source
m2.reset(ParseIR(buffer2, diag, context));
// Setup pass manager containing instcombine pass
// Apply pass manager to module m2
// Dump *new* content of module m2 (after performing passes).
Or, if you work from the outside, using "opt" tool, then it has an
equivalent option -print-module
Hope it helps,
2011/10/31 Himanshu Shekhar <imhimanshu91 at gmail.com>:
> I am getting to know how the Runtime Optimization feature of LLVM works and
> how I can use it. I want to know how I could print the results of any
> analysis and transformation pass. Say, I have a program written in c and I
> ran the edge-profiling pass onto it. Now I want to see the result. How could
> I do it?
> Also if I happen to change one of the passes inside folder
> /llvm/lib/Transforms/Instrumentation (say EdgeProfiling.cpp), then what all
> do I have to do to see the changes done in the pass. Please help me with the
> required steps.
> And is there any tool available which I use to see the control flow(step by
> step execution of the code) when I execute say the -insert-edge-profiling
> pass on my bitecode. If there is one, it would help me a lot to understand
> how the pass works and also in writing a new pass for my purpose.
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the LLVMdev