[llvm-dev] How to implement function pointer?

Yafei Liu via llvm-dev llvm-dev at lists.llvm.org
Tue Feb 26 02:14:48 PST 2019

Hi, I'm learning to use llvm api to generate IR code, I got two good
tutorials, https://llvm.org/docs/tutorial/ and
but non of those showed how to implement a function pointer(or at least
there is but I didn't find out).

For example I got a c style code like this:

int foo(int i) {
  return ++i;

int (*p)(int);

int main() {
  p = foo;

I turn it into IR code and found the sytex of a function pointer is:
@p = global i32 (i32)* null, align 8
I tried play with llvm::PointerType but I cannot get the sytex, so could
anyone teach me how to do this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190226/76c12a80/attachment.html>

More information about the llvm-dev mailing list