[LLVMdev] IR blocks for calling function pointers
avinash.ca at gmail.com
Mon Mar 23 19:04:41 PDT 2015
I am trying to create IR block for making a call to function pointer.
For creating the IR for a function call to "foo", with "foo" being defined
as "void foo(int)", I can use the "getOrInsertFunction" call from Module
class as follows:
Value *FooFunction = M.getOrInsertFunction(std::string("foo"),
I want to create a similar call, but to the pointer of foo ("foo_ptr" is
defined as "(void) *foo_ptr (int)"). In C code, I would just call
"foo_ptr(var)", and it would just work. But, replacing the function name
with the name of the function pointer, in the IRBlock does not work:
Value *FooFunctionPtr = M.getOrInsertFunction(std::string("foo_ptr"),
IRBlocks generated from the above crashes.
I see the LLVM blocks generated for a sample call to function pointer. It
looks as follows:
%4 = load void (i64)** @foo_ptr, align 8, !dbg !26
%call = call i32 %4(i32 %3), !dbg !26
What LLVM function calls should be used to generate the above IR blocks?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev