<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Dear Varun,<br>
      <br>
      First, the order of the allocas is likely not important.  Due to
      the way LLVM IR works, the ordering doesn't matter.  I typically
      only need to insert instructions in a particular order for
      cosmetic reasons (e.g., making the LLVM IR easier to read for
      debugging).<br>
      <br>
      That said, if you want your new alloca to appear after an original
      alloca, you should create a BasicBlock::iterator with the original
      alloca as an argument.  You then advance this iterator by 1
      element and assign it to an Instruction *.  This instruction is
      the one following the alloca and is the argument you want to use
      for the insertion point.  I think the following is what you would
      want:<br>
      <br>
      AllocaInst * AI = .... ;<br>
      ...<br>
      Instruction *InsertionPoint = ++(BasicBlock::iterator(AI));<br>
      <br>
      Regards,<br>
      <br>
      John Criswell<br>
      <br>
      On 12/28/16 6:09 AM, Varun Patil via llvm-dev wrote:<br>
    </div>
    <blockquote
cite="mid:CAF_UTeQ=TPvvK=dDUeYzaWBSMpYbxipqp=wvvsbX9xuHHmf=Dg@mail.gmail.com"
      type="cite">
      <meta http-equiv="Context-Type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>I want to insert new alloca Instruction after existing
          alloca Instruction in llvm pass so what attribute to be passed
          at last in following <br>
          newallocaI =  new
          AllocaInst(llvm::Type::getInt32PtrTy(context,0), //type<br>
                                                          0, //
          ArraySize<br>
        </div>
                                                        8, // Alignment<br>
        <div>                                                "p", // <a
            moz-do-not-send="true"
href="http://llvm.org/docs/doxygen/html/AArch64PromoteConstant_8cpp.html#a90f8350fecae261c25be85d38b451bff"
            class="el">const</a> <a moz-do-not-send="true"
            href="http://llvm.org/docs/doxygen/html/classllvm_1_1Twine.html"
            class="el">Twine</a> <a moz-do-not-send="true"
href="http://llvm.org/docs/doxygen/html/SymbolizableObjectFile_8cpp.html#ab104eb44fb0574709f0ceb43b50bdb63"
            class="el">Name</a><br>
                                                          allocaI);  //
          InsertBefore
          <div>
            <div>
              <div class="gmail_signature">
                <div dir="ltr">
                  <div>
                    <div dir="ltr">
                      <div>Presently I am passing previous allocaInstr
                        Poiter as last argument as i shown above So New
                        allocaInstr is inserting before previous
                        allocaInstr in LLVM IR as follows output<br>
                        <br>
                         %p1 = alloca i32*, align 8 // New Alloca
                        Instrctions  <br>
                         %b = alloca i32, align 4   // previous Alloca
                        Instrctions  <br>
                      </div>
                      <div><br>
                      </div>
                      <div>how can I get output like below<br>
                         %b = alloca i32, align 4   // previous Alloca
                        Instrctions<br>
                         %p1 = alloca i32*, align 8 // New Alloca
                        Instrctions  <br>
                        <br>
                      </div>
                      <div>Please help me to the needful Thank you<br>
                      </div>
                      <div><br>
                      </div>
                      Thanks and Regards
                      <div>Varun</div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
    </blockquote>
    <br>
    <p><br>
    </p>
    <pre class="moz-signature" cols="72">-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a class="moz-txt-link-freetext" href="http://www.cs.rochester.edu/u/criswell">http://www.cs.rochester.edu/u/criswell</a></pre>
  </body>
</html>