<div dir="ltr">Easiest thing to do would be to write the equivalent C code, throw it through Clang, and look at the IR it produces.<br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 12, 2015 at 3:00 PM, Kevin Hu <span dir="ltr"><<a href="mailto:hxy9243@gmail.com" target="_blank">hxy9243@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear all,<div><br></div><div><br></div><div>I'm writing an LLVM pass, and I want to insert a call instruction that takes a function pointer as a parameter. The effect would be the same as following:</div><div><br></div><div>atexit(foo);</div><div><br></div><div>Where foo is a function I insert with M.getOrInsertFunction(), which in LLVM is a Function class.</div><div><br></div><div>I searched for a while and did not come up with a satisfying answer. Should I create a Value class of pointer type, or a Int64Ty for a pointer? How do I get the pointer to the function I create? I also tried passing foo as Function* in LLVM as parameter to create CallInst directly, and I doesn't seem to work.</div><div><div><br></div><div>Any hints and enlightenment is appreciated. Many thanks.</div><div><br></div><div><br></div>Regards,<br><div><div dir="ltr">Yours,<div>Kevin Hu</div></div></div>
</div><img src="http://t.signalecinque.com/e1t/o/5/f18dQhb0S7ks8dDMPbW2n0x6l2B9gXrN7sKj6v5dj0qW64JvZH6538V-MdV5ZMQFLCHW2swVb-1k1H6H0?si=5235970534801408&pi=e09ba43a-17ec-4fb1-826d-8dcbc262b7ec" width="1" height="1"></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div></div>