-1

我正在尝试创建一个将加载的值传递给外部函数的传递。这就是我正在做的

cpProfFunc = M.getOrInsertFunction("_Z6cpProfiiiiii",Type::getVoidTy(*Context),Type::getInt8tInt8PtrTy(*Context),NULL); 
if(isa<LoadInst>(&(*BI)) )     //next in block iterator
    std::vector<Value*> a1(1);              
LoadInst *CI = dyn_cast<LoadInst>(BI);
a1[0]=dyn_cast<ConstantExpr>(CI->getPointerOperand());
CallInst* newInst = CallInst::Create(cpProf,a1,"");
BB->getInstList().insert((Instruction*)CI, newInst);

这给了我错误。我不知道我错在哪里。有人,请纠正我。

4

1 回答 1

0

您写道您收到错误:

Stack dump:
0.  Program arguments: opt -load /home/anshul/llvm/llvm-3.2/Release+Asserts/lib/Ass1Pri.so -anshul_insert
1.  Running pass 'test function exist' on module '<stdin>'.
./myscript: line 6: 10726 Segmentation fault (core dumped)
opt -load /home/anshul/llvm/llvm-3.2/Release+Asserts/lib/Ass1Pri.so -anshul_insert < a.bc > b1.bc
'main' function not found in module.

因此,似乎一个名为“测试函数存在”的过程正试图实际运行一些位码文件(可能在其上调用 lli),但main该文件中缺少一个函数。

于 2013-03-10T09:12:26.727 回答