[LLVMdev] whether these transformations are doable and how?
kennethuil at gmail.com
Fri Apr 9 05:48:12 PDT 2010
On Fri, Apr 9, 2010 at 6:29 AM, Ning Wang <neal.wang at gmail.com> wrote:
> Hi folk,
> I'm a newbie to llvm, please first forgive my naive questions. I want to
> instrument llvm code to do some run-time monitoring work. After reading
> some of the llvm documentation, it begins clear to me that I can do the
> instrumentation in a transformation pass. There are several things I want
> to do in the transformation pass, but I'm not sure whether they are doable
> and how to do them even after I read the documentation. I would be very
> appreciate if anyone can answer my questions or give me hints of how to do
> 1. can I add more global memory objects to a module? any hint how to do
> it? do I need to derive a pass from ModulePass?
Yes, a ModulePass should be able to do that.
> 2. can I add more stack allocated memory objects to a function? the answer
> seems yes, any hint how to do it?
In a FunctionPass, insert an alloca instruction in the entry block to
add a stack allocated memory object.
> 3. can I modify a function to take extra formal parameters? can I update
> all calls of the original function to take extra actual paramters? The
> function might be called across multiple modules. It seems this has to be
> done at both ModulePass and FunctionPass levels.
A pass can only work with one module. You can use llvm-link to
combine multiple modules into a single module before you run the pass.
Or you can make sure opt runs on all your modules, but in that case
you'll have to be able to apply the transformation to a call without
necessarily being able to see the definition.
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the llvm-dev