Cross-module optimization

Hi!

I want to load several modules with BitcodeReader and build a module
with IRBuilder and then optimize them alltogether. Actually I want
functions from loaded modules to be inlined in functions that I've built.
Is it possible with LLVM? As I understood PassManager runs upon only
one module at once.

May be is there some workaround? Like joining all the modules in one
and then optimize it. Unfortunately I couldn't find a way to join modules.

Thanks,
Andrii

Hi Andrii,

May be is there some workaround? Like joining all the modules in one
and then optimize it. Unfortunately I couldn't find a way to join modules.

llvm-link does this.

Ciao,

Duncan.

May be is there some workaround? Like joining all the modules in one
and then optimize it. Unfortunately I couldn't find a way to join modules.

llvm-link does this.

Thanks for answer, Duncan!
But I want to do it in my program and then run it with ExecutionEngine...

Hey, but I took a look inside of llvm-link and found a Linker class
which does modules linking! :slight_smile:

So, is this the right answer? To optimize modules altogether link them before?

Andrii

So, is this the right answer? To optimize modules altogether link them before?

Yes.

Ciao,

Duncan.