[LLVMdev] Self-referential function pointer

Cameron McInally cameron.mcinally at nyu.edu
Fri Jul 6 04:44:32 PDT 2012


Hey guys,

I could use some advice on a special case of a function pointer as a formal
argument. I would like the function pointer type to contain the actual
signature of the function, i.e. not a pointer to var args function. This
becomes an issue when I have a function which can take a pointer to itself
as an argument... our terminology for this is "a recursive procedure". That
is, of course, in a context where C-like recursion is not intrinsic to the
language.

With LLVM 2.9, the solution was to create an OpaqueType when creating the
function type signature, use the OpaqueType as the function pointer
argument type, and then finish the function type signature later. No
problem.

If I'm not mistaken, only StructType can be self-referential in LLVM 3.0
and beyond. So, is it not possible to have a self-referencing FunctionType,
short of making the function pointer formals var args? Has anyone developed
a solution for similar behavior?

Ty,
Cameron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120706/73682c1a/attachment.html>


More information about the llvm-dev mailing list