[LLVMdev] Opt error
Hassan, Ahmad
ahmad.hassan at sap.com
Thu Jan 3 07:26:42 PST 2013
Hi Team,
I am migrating one of the Pass that was written for llvm2.2 or older to llvm3.1. The code snippet looks like the following:
Constant *func;
void add( Module *M) {
func = M->getOrInsertFunction("func", Type::getVoidTy(M->getContext()), NULL);
}
virtual bool runOnModule(Module &M) {
add (&M);
for(Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {
Function *fun = dyn_cast<Function>(F);
Value *Opts[1];
BasicBlock &bb = F->getEntryBlock(), *newBB;
newBB = BasicBlock::Create(M.getContext(), "initfunc", F, &bb);
CallInst::Create(func, makeArrayRef(Opts, 1) , "", newBB);
BranchInst::Create(&bb, newBB);
}
}
The pass compiles fine but when I use 'opt' to instrument a simple C program then I get the following exception:
$ opt -o a.bc -load /data/llvm3.1/Release+Asserts/lib/Dat.so -MyPass < malloc.bc
opt: Instructions.cpp:269: void llvm::CallInst::init(llvm::Value*, llvm::ArrayRef<llvm::Value*>, const llvm::Twine&): Assertion `(Args.size() == FTy->getNumParams() || (FTy->isVarArg() && Args.size() > FTy->getNumParams())) && "Calling a function with bad signature!"' failed.
In older llvm, I had the following line:
CallInst::Create(func, Opts, Opts , "", newBB);
Which I have now modified for llvm3.1 to:
CallInst::Create(func, makeArrayRef(Opts, 1) , "", newBB);
Please can anyone tell the reason of this opt error?
Thanks.
--Ahmad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130103/0b1b5c1c/attachment.html>
More information about the llvm-dev
mailing list