<div dir="ltr"><div>So one way might look like this:</div><div><br></div><div>IRBuilder<> Builder(&*BB); // BB = Function::iterator OR IRBuilder<> Builder(CallInst->getParent());</div><div>Builder.SetInsertPoint(CallInst);</div><div>InstructionClass *YourNewInstruction = builder.CreateInstructionClass(.....); // InstructionClass = type of instruction you are inserting</div><div><br></div><div>-Ryan</div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 3, 2016 at 6:04 PM, Ryan Taylor <span dir="ltr"><<a href="mailto:ryta1203@gmail.com" target="_blank">ryta1203@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Take a look at IRBuilder and SetInsertPoint().</p>
<div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Sep 3, 2016 18:02, "SHUCAI YAO via llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br type="attribution"></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><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></div></div>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank" rel="noreferrer">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div></div>
</blockquote></div><br></div>