Confused about Function vs FunctionCallee, etc

I’m confused by Function and FunctionCallee semantics.

Why is FunctionCallee a {Value, FunctionType} pair and not a {Function, FunctionType} pair? Can the Value sometimes be something other than a Function?

IRBuilder has CreateCall() flavours taking a FunctionCallee and a Function. Is one of these going away longer term? I.e., I’m currently using Function::Create() to create my own (internal) functions, but getOrInsertFunction() to (e.g.,) find external symbols in the JIT. Should I be using getOrInsertFunction() for my own functions as well? Or Function::Create() for both? (Can you Function::Create and have the JIT find external symbols?



Yes, it can be an arbitrary “ptr”. This represents an indirect call (e.g. calling a C function pointer).

No, the current API should be stable.

getOrInsertFunction() is just a helper to check “if this symbol already exists in the module, return it; otherwise call Function::Create()”.

Thank you! That helps.