LLVMBuildCall2 function type

For a call to LLVMBuildCall2 you can find the LLVMValueRef using LLVMGetNamedFunction but I don’t see anyway to get the function type (LLVMTypeRef) for said function. Basically I would exact another function to act on the output of LLVMGetNamedFunction.

Here’s an example of the call I’m trying to make.

LLVMBuildCall2(builder, /* THIS TYPE */, LLVMGetNamedFunction(module, "print"), &arg, 1, "");

Is this not provided in the API and should I keep track of it myself?

For global functions you can use LLVMGlobalGetValueType(). If you want to support indirect calls you need to keep track of types yourself.

1 Like

Ok, I thought LLVMAddFunction would know how to find that type since it was passed in. Too bad because that would be easier to track using a single reference.