llvm createCall调用具有错误签名的函数

llvm createCall调用具有错误签名的函数,llvm,Llvm,我想在LLVM中创建一个函数,它是一个适配器,只有一个函数调用foo(idx,mn)。foo的函数原型是void foo(unsigned char,const char*) //仅具有函数调用foo(idx,mn)的适配器函数 llvm::Function*createCallFun(llvm::Module*M,llvm::Function*exit\u f){ llvm::LLVMContext&Ctx=M->getContext(); llvm::Function*foo_f=foo_原

我想在LLVM中创建一个函数,它是一个适配器,只有一个函数调用foo(idx,mn)。foo的函数原型是
void foo(unsigned char,const char*)

//仅具有函数调用foo(idx,mn)的适配器函数
llvm::Function*createCallFun(llvm::Module*M,llvm::Function*exit\u f){
llvm::LLVMContext&Ctx=M->getContext();
llvm::Function*foo_f=foo_原型(Ctx,M);
llvm::Constant*c=M->getOrInsertFunction(“\uu call\u fun”,FunctionType::getVoidTy(Ctx),llvm::Type::getInt32Ty(Ctx),llvm::Type::getInt32Ty(Ctx),NULL);
llvm::Function*call\u fun\u f=llvm::cast(c);
llvm::BasicBlock*entry=llvm::BasicBlock::Create(llvm::getGlobalContext(),“entry”,call\u fun\u f);
llvm::IRBuilder(条目);
llvm::Function::arg_迭代器args=调用函数->arg_begin();
llvm::Value*idx=&*args++;
idx->setName(“idx”);
llvm::Value*mn=&*args++;
mn->setName(“mn”);
llvm::Value*greater=builder.CreateICmpSGE(idx,mn,“tmp”);
std::向量fun_args;
有趣的动作。向后推(更大);
有趣的参数。推回(错误消息);
CreateCall(foo\u f,fun\u args);
回电(fun);;
}
然后我得到了这个错误:

lib/IR/Instructions.cpp:245:void llvm::CallInst::init(llvm::FunctionType*,llvm::Value*,llvm::ArrayRef,llvm::ArrayRef>,const llvm::Twine&):断言`(i>=FTy->getNumParams()| FTy->getParamType(i)==Args[i]>getType())&&“调用签名错误的函数!”失败


foo的第一个参数似乎存在类型不匹配。如何将值
greater
转换为
无符号字符
类型?

我通过使用
CreateZExt
转换
greater
修复了此错误

llvm::Value *castuchar =
    builder.CreateZExt(greater, llvm::Type::getInt8Ty(Ctx), "tmp1");

我通过使用
CreateZExt
转换
greater
修复了这个错误

llvm::Value *castuchar =
    builder.CreateZExt(greater, llvm::Type::getInt8Ty(Ctx), "tmp1");