Using argument in another module

Hi everyone,

  I am building a function that would call a function in another module,

I found this related thread

http://llvm.1065342.n5.nabble.com/Using-a-function-from-another-module-td10506.html

All my functions have prototype

int f(myStruct * c);

here comes my problems

If I have Function* f1,*f2

f2 is in another module, f1 is the function I am building.

Somewhere in f1 , I set

builder.CreateCall(f2,f1->arg_begin()); // builder is
IRBuilder, its context is the same as f1

When I run my program, I get

llvm/lib/VMCore/Instructions.cpp:274: void
llvm::CallInst::init(llvm::Value*, llvm::ArrayRef<llvm::Value*>, const
llvm::Twine&): Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i)
== Args[i]->getType()) && "Calling a function with a bad signature!"'
failed.

I found another thread having the same problem

http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-July/052083.html

It says that the problem results from parameter in different context.

In that thread, it's still unsolved.

The reason I have this problem is that I am using many threads to create and
build LLVM functions, each thread

has its own LLVMContext, and they may execute functions built by other
threads.

Does anyone have idea on how to solve that ?

Have A Nice Day

Chia Lun Liu

Hi everyone,

  I am building a function that would call a function in another module,

I found this related thread

http://llvm.1065342.n5.nabble.com/Using-a-function-from-another-module-td10506.html

All my functions have prototype

int f(myStruct * c);

here comes my problems

If I have Function* f1,*f2

f2 is in another module, f1 is the function I am building.

Somewhere in f1 , I set

builder.CreateCall(f2,f1->arg_begin()); // builder is
IRBuilder, its context is the same as f1

When I run my program, I get

llvm/lib/VMCore/Instructions.cpp:274: void
llvm::CallInst::init(llvm::Value*, llvm::ArrayRef<llvm::Value*>, const
llvm::Twine&): Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i)
== Args[i]->getType()) && "Calling a function with a bad signature!"'
failed.

I found another thread having the same problem

http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-July/052083.html

It says that the problem results from parameter in different context.

In that thread, it's still unsolved.

The reason I have this problem is that I am using many threads to create and
build LLVM functions, each thread

has its own LLVMContext, and they may execute functions built by other
threads.

(caveat: I'm not a specialist in LLVM issues, I work mostly with Clang)

I'm confused - are you using Functions built with one LLVMContext in
another LLVMContext? I'm pretty sure that would be invalid. You'd have
to create an external declaration of the function in any LLVMContext
you want to use it in I would think.

You shouldn't ever be mixing things between LLVMContexts.

- David