<div dir="ltr"><div>Yes. That is exactly what I was looking for. I tried it, and it works.<br></div>Thanks, Tim!<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 23, 2015 at 8:49 PM, Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<span class=""><br>
On 23 March 2015 at 19:04, Avinash Chiganmi <<a href="mailto:avinash.ca@gmail.com">avinash.ca@gmail.com</a>> wrote:<br>
>   %4 = load void (i64)** @foo_ptr, align 8, !dbg !26<br>
>   %call = call i32 %4(i32 %3), !dbg !26<br>
><br>
> What LLVM function calls should be used to generate the above IR blocks?<br>
<br>
</span>I think the key thing you should notice in the "correct" code is that<br>
@foo_ptr isn't actually a function. It's a generic global with type<br>
void(i64)* (which means, as with all other LLVM globals that the<br>
symbol @foo_ptr has type void(i64)** and you must load it to get the<br>
actual value of the function pointer). If you look at the module where<br>
it's defined you'll see something like<br>
<br>
    @foo_ptr = global void(i64)* null<br>
<br>
instead of a function definition. So you'd get a handle to it via a call like<br>
<br>
    auto FooFunctionPtr = M.getOrInsertGlobal("foo_ptr",<br>
PointerType::get(FunctionType::get(IRB.getVoidTy(), FooArgs, false)));<br>
<br>
after that (and given that FooFunctionPtr is a Value with type<br>
"void(i64)**") there's really only one sane set of operations you can<br>
perform on it:<br>
<br>
    auto FooFunction = IRB.getLoad(FooFunctionPtr)<br>
    IRB.CreateCall(FooFunction, IRB.CreateLoad(LenAlloca));<br>
<br>
Does that help?<br>
<br>
Cheers.<br>
<span class="HOEnZb"><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br></div>