<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 3, 2016, at 6:18 PM, Ryan Taylor via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">So one way might look like this:</div><div class=""><br class=""></div><div class="">IRBuilder<> Builder(&*BB); // BB = Function::iterator OR IRBuilder<> Builder(CallInst->getParent());</div><div class="">Builder.SetInsertPoint(CallInst);</div><div class="">InstructionClass *YourNewInstruction = builder.CreateInstructionClass(.....); // InstructionClass = type of instruction you are inserting</div><div class=""></div><div class=""><br class=""></div></div></div></blockquote><div><br class=""></div>I’m not sure how the IRBuilder would work at the MI level, as Shucai was asking.<div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sat, Sep 3, 2016 at 6:04 PM, Ryan Taylor <span dir="ltr" class=""><<a href="mailto:ryta1203@gmail.com" target="_blank" class="">ryta1203@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr" class="">Take a look at IRBuilder and SetInsertPoint().</p>
<div class="gmail_extra"><br class=""><div class="gmail_quote"><div class=""><div class="h5">On Sep 3, 2016 18:02, "SHUCAI YAO via llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>> wrote:<br type="attribution" class=""></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><div class="h5"><div dir="ltr" class=""><span style="font-family:arial,helvetica,sans-serif;font-size:13px" class="">I'm trying to insert some instructions before each function calls (before arguments push):</span><br class=""><div class=""><span style="font-family:arial,helvetica,sans-serif;font-size:13px" class="">   lea %EAX, label                      ----- new instructions</span></div><div class=""><span style="font-family:arial,helvetica,sans-serif;font-size:13px" class="">   mov [ESP+stacksize], %EAX  ----- new instructions</span></div><div class=""><span style="font-family:arial,helvetica,sans-serif;font-size:13px" class="">   push arg1</span></div><div class=""><span style="font-family:arial,helvetica,sans-serif;font-size:13px" class="">   push arg2</span></div><div class=""><span style="font-family:arial,helvetica,sans-serif;font-size:13px" class="">   ...</span></div><div class=""><span style="font-family:arial,helvetica,sans-serif;font-size:13px" class="">   push argn</span></div><div class=""><span style="font-family:arial,helvetica,sans-serif;font-size:13px" class="">   call callee_name</span></div><div class=""><span style="font-family:arial,helvetica,sans-serif;font-size:13px" class=""><br class=""></span></div><div class=""><span style="font-family:arial,helvetica,sans-serif;font-size:13px" class="">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></div></div></blockquote></div></div></blockquote></div></div></div></blockquote><div><br class=""></div><div>Can you describe more precisely what are you trying to achieve?</div><div>I.e. what are these instructions? Why do you want to do that? It may lead to a different answer.</div><div><br class=""></div><div>— </div><div>Mehdi</div></div></body></html>