[LLVMdev] Calling functions across modules. And those pesky vectors!

Gordon Henriksen gordonhenriksen at mac.com
Fri Jan 4 06:57:52 PST 2008

On 2008-01-03, at 21:14, Danny wrote:

> Before I get started with more questions, thanks for the prompt  
> reply on my last set question, that was much appreciated.
> First, I found references to lazy inling and optimizations for  
> calling functions across modules, but I can't figure out how to do  
> that. If I just take a Function* that I got out of one module and  
> call it from the other, it doesn't work. What's the general method  
> for dealing with interactions between modules? Up until this point,  
> everything I've done has been within one module.

One module should contain a declaration of the function (with no  
body), and the other should contain the definition (with a body).

Generally speaking, the modules then need to be linked together (i.e.,  
become one module) before the declaration can be resolved to the  
definition. This can happen either before or after compilation.

In a JIT context, you can skip linking. Instead, just call  
addModuleProvider for as many additional modules as you have.

> Second, I was under the impression that vector types were fairly  
> well, but I can't seem to get a simple function which takes in and  
> returns vectors to work properly. And I don't understand the error.  
> I made a simple function which was just supposed to multiply two 3  
> component float vectors and return the result:

You may be treading on thin ice, here. There used to be a requirement  
that vectors have power-of-two widths. File bugs. :)

— Gordon

More information about the llvm-dev mailing list