[llvm-dev] llvm::Linker::linkModules destroys source module

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] llvm::Linker::linkModules destroys source module

Alberto Barbaro via llvm-dev

We have some LLVM 3.4 based code that we are now trying to upgrade. There used to be the following API in LLVM 3.4 which is now gone:

 

Linker::LinkModules(dst, src, Linker::PreserveSource, &error);

 

The current function Linker::linkModules wants to take ownership of src and destroys it on return.

 

In our use case, src is a module containing a predefined set of inline functions. We link src with dst, optimize dst, emit object code for dst, destroy dst and then create a new dst module from our code generator and repeat this process. The src module is a constant throughout. What is the recommended way of doing something like this in current version of LLVM? Is there a way of copying only what is needed from src into dst and then updating all the call instructions in dst that refer to src functions?

 

Or do I just have to write something like this myself and not use linkModules?

 

/Riyaz


_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] llvm::Linker::linkModules destroys source module

Alberto Barbaro via llvm-dev
You might want http://llvm.org/doxygen/Cloning_8h.html to copy the Module before you link it in?

Looks like this functionality was removed a few years ago because it had bitrotted/was broken: http://llvm.org/viewvc/llvm-project?view=revision&revision=220741 

- Dave

On Mon, Nov 12, 2018 at 10:10 PM Riyaz Puthiyapurayil via llvm-dev <[hidden email]> wrote:

We have some LLVM 3.4 based code that we are now trying to upgrade. There used to be the following API in LLVM 3.4 which is now gone:

 

Linker::LinkModules(dst, src, Linker::PreserveSource, &error);

 

The current function Linker::linkModules wants to take ownership of src and destroys it on return.

 

In our use case, src is a module containing a predefined set of inline functions. We link src with dst, optimize dst, emit object code for dst, destroy dst and then create a new dst module from our code generator and repeat this process. The src module is a constant throughout. What is the recommended way of doing something like this in current version of LLVM? Is there a way of copying only what is needed from src into dst and then updating all the call instructions in dst that refer to src functions?

 

Or do I just have to write something like this myself and not use linkModules?

 

/Riyaz

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev