[LLVMdev] Is it possible to inline Functions without using LLVM JIT Framework?

Mian M. Hamayun mian-muhammad.hamayun at imag.fr
Mon Sep 5 06:43:56 PDT 2011


Dear Jeff,

This is exactly what I am interested in. I tried this, and it works for 
simple functions that don't use other functions or global data.
But for functions dependent on external/global references, it poses some 
problems as I also need to copy/clone these references. I am still 
looking into this ... an example from anyone would be great ... :)

I have found another way to tackle this problem. Your comments are still 
desirable on any potential side-effects. Here is what I do

- Clone input the module using CloneModule Function.
- Modify the Linkage type to GlobalValue::InternalLinkage for all 
function definitions.
   (So that they don't conflict with other modules at link time)
- Add my Generated function to the Cloned Module.
- Run Optimization and Inliner Passes.
   (This Inlines the functions and removes un-used functions/globals)
- Emit the Optimized BitCode Module.

Any Comments?

Thanks again,
Hamayun


On 09/02/2011 04:29 PM, Jeff Fifield wrote:
> On Fri, Sep 2, 2011 at 4:23 AM, Mian M. Hamayun
> <mian-muhammad.hamayun at imag.fr>  wrote:
>
>> But I am also looking into the possibility of doing the same using LLVM Pass
>> Manager (Without using llvm-ld). This looks difficult due to the fact that
>> the function definitions ought to be in the same module as the caller, in
>> order to be inlined and then optimized onwards, I guess !!! (Correct me If I
>> am Wrong at this)
>
> I have a system where I need to do this quite often.  In my inlining
> pass I open the module containing the function I wish to inline, copy
> the function into the current module, then call InlineFunction.
>
> -Jeff
>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3781 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110905/787fe2ff/attachment.bin>


More information about the llvm-dev mailing list