Mian M. Hamayun
2011-Sep-02 10:23 UTC
[LLVMdev] Is it possible to inline Functions without using LLVM JIT Framework?
Thanks Eric, Jim and Geovani for your responses. Yes, we can combine two or more bitcode modules using llvm-ld and in this way functions can be inlined and optimized during this process. 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) Thanks Again, Hamayun P.S. @Geovani: "You have tried do it in semantical phase?" Which LLVM Passes are you referring here ? Because I am working at the LLVM-IR Level, where I generate LLVM-IR modules, optimize them and then compile them for a given target. On 09/01/2011 06:41 PM, Jim Grosbach wrote:> To do it manually, llvm-ld your modules to get a single module with both, then run opt on the result to optimize it. From source code, you can just use -O4 to the compiler on a system with a suitable linker (standard ld on OSX; binutils+gold plugin on Linux, for example). > > -Jim > > On Sep 1, 2011, at 9:27 AM, Mian M. Hamayun wrote: > >> Hi Everyone, >> >> Hopefully this question is not too absurd. >> >> Actually I created an example in LLVM, where I generate two modules, one containing the function definition and the other module calling this function. >> (Question related to this was posted on this mailing list recently) >> >> Now I want to know, whether it is possible to "inline" the definition of this function in the caller module, using some optimization pass etc? >> >> I have previously experimented with LLVM's JIT Framework, and we can do something similar over there. But now I am interested in doing this without JIT Framework. >> >> Any ideas/suggestions/comments on how could we accomplish this? >> >> Thanks in advance, >> Mian M. Hamayun >> Grenoble, France. >> >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- 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/20110902/20fa7d3d/attachment.bin>
geovanisouza92 at gmail.com
2011-Sep-02 11:38 UTC
[LLVMdev] Is it possible to inline Functions without using LLVM JIT Framework?
Oh, Mian, sorry for my fool reply... I was thinking that you do it in high-level... Your idea is cool, 'cause allow integrate an inline methods generated from diferent languages, right? Thanks 2011/9/2 Mian M. Hamayun <mian-muhammad.hamayun at imag.fr>> Thanks Eric, Jim and Geovani for your responses. > > Yes, we can combine two or more bitcode modules using llvm-ld and in this > way functions can be inlined and optimized during this process. > > 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) > > Thanks Again, > Hamayun > > P.S. @Geovani: "You have tried do it in semantical phase?" > Which LLVM Passes are you referring here ? Because I am working at the > LLVM-IR Level, where I generate LLVM-IR modules, optimize them and then > compile them for a given target. > > > > On 09/01/2011 06:41 PM, Jim Grosbach wrote: > >> To do it manually, llvm-ld your modules to get a single module with both, >> then run opt on the result to optimize it. From source code, you can just >> use -O4 to the compiler on a system with a suitable linker (standard ld on >> OSX; binutils+gold plugin on Linux, for example). >> >> -Jim >> >> On Sep 1, 2011, at 9:27 AM, Mian M. Hamayun wrote: >> >> Hi Everyone, >>> >>> Hopefully this question is not too absurd. >>> >>> Actually I created an example in LLVM, where I generate two modules, one >>> containing the function definition and the other module calling this >>> function. >>> (Question related to this was posted on this mailing list recently) >>> >>> Now I want to know, whether it is possible to "inline" the definition of >>> this function in the caller module, using some optimization pass etc? >>> >>> I have previously experimented with LLVM's JIT Framework, and we can do >>> something similar over there. But now I am interested in doing this without >>> JIT Framework. >>> >>> Any ideas/suggestions/comments on how could we accomplish this? >>> >>> Thanks in advance, >>> Mian M. Hamayun >>> Grenoble, France. >>> >>> >>> ______________________________**_________________ >>> LLVM Developers mailing list >>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >>> http://lists.cs.uiuc.edu/**mailman/listinfo/llvmdev<http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev> >>> >> >> > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- @geovanisouza92 - Geovani de Souza -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110902/099cc3c2/attachment.html>
Jeff Fifield
2011-Sep-02 14:29 UTC
[LLVMdev] Is it possible to inline Functions without using LLVM JIT Framework?
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
Mian M. Hamayun
2011-Sep-05 13:43 UTC
[LLVMdev] Is it possible to inline Functions without using LLVM JIT Framework?
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>
Reasonably Related Threads
- [LLVMdev] Is it possible to inline Functions without using LLVM JIT Framework?
- [LLVMdev] Is it possible to inline Functions without using LLVM JIT Framework?
- [LLVMdev] Is it possible to inline Functions without using LLVM JIT Framework?
- [LLVMdev] LLVM JIT on a Baremetal x86 Machine !!!
- [LLVMdev] LLVM JIT on a Baremetal x86 Machine !!!