[LLVMdev] Passing an array to an external function

SArora silkyar at umich.edu
Sun Jan 27 09:05:50 PST 2013


Hi,

I tried passing the array directly using and changing the
getorInsertFunction accordingly but this didn't work. It fails with
Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) ==
Args[i]->getType()) && "Calling a function with a bad signature!"' failed. 

hookFunc = M.getOrInsertFunction("hook", Type::getVoidTy(M.getContext()),  
llvm::ArrayType::get(llvm::Type::getInt32Ty(M.getContext()),2), (Type*)0);
.....
Args[0] =
ConstantArray::get(llvm::ArrayType::get(llvm::Type::getInt32Ty(BI->getContext()),2),
arr);

I tried using index 0 in the GEP, but it fails with

7  opt             0x00000000006c59f5 bool llvm::isa<llvm::Constant,
llvm::Value*>(llvm::Value* const&) + 24
8  opt             0x00000000006c5a0f llvm::cast_retty<llvm::Constant,
llvm::Value*>::ret_type llvm::cast<llvm::Constant,
llvm::Value*>(llvm::Value* const&) + 24
9  opt             0x0000000000b2b22f
10 opt             0x0000000000b2a4fe
llvm::ConstantFoldGetElementPtr(llvm::Constant*, bool,
llvm::ArrayRef<llvm::Value*>) + 55
11 opt             0x0000000000b33df2
llvm::ConstantExpr::getGetElementPtr(llvm::Constant*,
llvm::ArrayRef<llvm::Value*>, bool) + 82

Probably the ConstantArray could't be casted to Value*. Any ideas? 
Thanks!




--
View this message in context: http://llvm.1065342.n5.nabble.com/Passing-an-array-to-an-external-function-tp54208p54220.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.



More information about the llvm-dev mailing list