<p dir="ltr">Take a look at IRBuilder and SetInsertPoint().</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Sep 3, 2016 18:02, "SHUCAI YAO via llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="font-family:arial,helvetica,sans-serif;font-size:13px">I'm trying to insert some instructions before each function calls (before arguments push):</span><br><div><span style="font-family:arial,helvetica,sans-serif;font-size:13px">   lea %EAX, label                      ----- new instructions</span></div><div><span style="font-family:arial,helvetica,sans-serif;font-size:13px">   mov [ESP+stacksize], %EAX  ----- new instructions</span></div><div><span style="font-family:arial,helvetica,sans-serif;font-size:13px">   push arg1</span></div><div><span style="font-family:arial,helvetica,sans-serif;font-size:13px">   push arg2</span></div><div><span style="font-family:arial,helvetica,sans-serif;font-size:13px">   ...</span></div><div><span style="font-family:arial,helvetica,sans-serif;font-size:13px">   push argn</span></div><div><span style="font-family:arial,helvetica,sans-serif;font-size:13px">   call callee_name</span></div><div><span style="font-family:arial,helvetica,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,helvetica,sans-serif;font-size:13px">I am a newbie to LLVM. I tried to use buildMI() to insert the instructions in the lowercall() function. But I couldn't put these instructions in the right positions. Is there a way to locate the position by using MachineBasicBlock iterator?</span></div><div><span style="font-family:arial,helvetica,sans-serif;font-size:13px"><br></span></div><div><div style="font-size:12.8px"><span style="font-family:arial,helvetica,sans-serif;font-size:13px">Any suggestions are appreciated.</span></div><div style="font-size:12.8px"><span style="font-family:arial,helvetica,sans-serif;font-size:13px"><br></span></div><div style="font-size:12.8px"><span style="font-family:arial,helvetica,sans-serif;font-size:13px">Thanks!</span></div></div><div style="font-size:12.8px"><span style="font-family:arial,helvetica,sans-serif;font-size:13px">Shucai</span></div><div><span style="font-family:arial,helvetica,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,helvetica,sans-serif;font-size:13px"><br></span></div></div>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div></div>