FunctionType* funcType = FunctionType::get(int32Ty, {int32Ty}, false); Function* func = Function::Create(funcType, Function::ExternalLinkage, "add", module); CallInst* callInst = CallInst::Create(func, {ConstantInt::get(int32Ty, 2)}, "result", basicBlock); callInst->setCallingConv(CallingConv::C);
FunctionType* funcType = FunctionType::get(voidTy, {}, false); Function* func = Function::Create(funcType, Function::ExternalLinkage, "print", module); CallInst* callInst = CallInst::Create(func, {}, "", basicBlock); callInst->setCallingConv(CallingConv::X86_StdCall);In this example, we create a function `print` that takes no parameters and returns nothing. We then create a call instruction `callInst` to call the `print` function with no arguments. We set the calling convention for the call instruction to the `X86_StdCall` calling convention. The `CallInst` class is part of the LLVM Core libraries.