Pass void pointer to LLVM IRBuilder CreateCall

Viewed 1326

I am creating an LLVM function call. How can I pass void pointer as an argument to that call. I have "_testFunc" as my function and need to pass void pointer as argument.

llvm::Function *testFunc= m_mod->getFunction("_testFunc");

llvm::IRBuilder<> builder(instruction.getNextNode());

llvm::Value *arg = argument is void pointer

builder.CreateCall(testFunc, arg);

So this arg has to be a void pointer.

1 Answers

There is no 'void*' type in LLVM IR. Use i8* instead.

If you want to specify the actual value of the "void*" just create a constant integer and cast in to a i8* (It's kind of complicated for what it actually does but it's the only way).

Otherwise if you just want a type for void* use i8*.

Related