LLVM insert intrinsic function Cos
I am trying to insert intrinsic cos() function call to LLVM pass. My code in a 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); When I leave out last line generated IR is: define i32 @main() nounwind uwtable { entry: ... } declare float @llvm.cos.f32(float) nounwind readonly , but with CallInst included all i get is: 0 opt 0x000000000094f4bf 1 opt 0x000000000094f9c9 2