Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Function LLVM插入内函数Cos_Function_Insert_Llvm_Trigonometry - Fatal编程技术网

Function LLVM插入内函数Cos

Function LLVM插入内函数Cos,function,insert,llvm,trigonometry,Function,Insert,Llvm,Trigonometry,我正在尝试将内部cos()函数调用插入LLVM pass。FunctionPass中的我的代码: std::vector<Type *> arg_type; arg_type.push_back(Type::getFloatTy(getGlobalContext())); Function *fun = Intrinsic::getDeclaration(F.getParent(), Intrinsic::cos, arg_type); CallInst* callInst = Ca

我正在尝试将内部cos()函数调用插入LLVM pass。FunctionPass中的我的代码:

std::vector<Type *> arg_type;
arg_type.push_back(Type::getFloatTy(getGlobalContext()));
Function *fun = Intrinsic::getDeclaration(F.getParent(), Intrinsic::cos, arg_type);
CallInst* callInst = CallInst::Create(fun, args, Twine("cos"), (Instruction *)&I);
,但包括CallInst后,我得到的是:

0  opt                0x000000000094f4bf
1  opt                0x000000000094f9c9
2  libpthread.so.0    0x00007fb92b652cb0
3  opt                0x00000000008be244 llvm::Instruction::Instruction(llvm::Type*, unsigned int, llvm::Use*, unsigned int, llvm::Instruction*) + 148
4  LLVMObfuscation.so 0x00007fb92a66c52f
5  LLVMObfuscation.so 0x00007fb92a66c9a5
6  LLVMObfuscation.so 0x00007fb92a66df21
7  opt                0x00000000008e921f llvm::FPPassManager::runOnFunction(llvm::Function&) + 591
8  opt                0x00000000008e9293 llvm::FPPassManager::runOnModule(llvm::Module&) + 51
9  opt                0x00000000008e8f34 llvm::MPPassManager::runOnModule(llvm::Module&) + 532
10 opt                0x00000000008ea4fb llvm::PassManagerImpl::run(llvm::Module&) + 171
11 opt                0x0000000000496208 main + 4104
12 libc.so.6          0x00007fb92a89376d __libc_start_main + 237
13 opt                0x000000000049cfe5
我还需要做什么?我想我不需要在模块中定义这个函数

发送到函数的参数定义如下:

std::vector<Value *> args;
args.push_back(fp);
变量I是inst_迭代器,但我在循环外部执行此操作


谢谢。

我建议您使用
IRBuilder
。它简化了LLVM通道内部的IR生成。在您的情况下,您可以这样使用它:

std::vector<Type *> arg_type;
arg_type.push_back(Type::getFloatTy(getGlobalContext()));
Function *fun = Intrinsic::getDeclaration(F.getParent(), Intrinsic::cos, arg_type);
IRBuilder<> Builder(&I);
Builder.CreateCall(fun, args);
std::向量arg_类型;
arg_type.push_back(type::getFloatTy(getGlobalContext());
函数*fun=内在::getDeclaration(F.getParent(),内在::cos,arg_类型);
IRBuilder&I;
CreateCall(fun,args);
Instruction *fp = BinaryOperator::Create(Instruction::FSub, ...
std::vector<Type *> arg_type;
arg_type.push_back(Type::getFloatTy(getGlobalContext()));
Function *fun = Intrinsic::getDeclaration(F.getParent(), Intrinsic::cos, arg_type);
IRBuilder<> Builder(&I);
Builder.CreateCall(fun, args);