<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 12/12/11 10:25 AM, neda 8664 wrote:
    <blockquote
cite="mid:CAHbEVmT_mY3aUu5LMVvYg6RUgd0SaqhA2RE5wJhzc-RYz0EfQw@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <p class="MsoNormal">Thank you for your reply</p>
      Yes, I change them, <span
        style="text-align:-webkit-auto;word-spacing:0px">so what should
        I do for another loops?</span><br>
    </blockquote>
    <br>
    I don't really know what you should do since I don't know what your
    code does.  All I know is that it's changing the function's
    control-flow graph.<br>
    <br>
    If you're not modifying the structure of the loops in the function,
    then you can probably just fix the problem by using a worklist-style
    algorithm.  First loop through the basic blocks in the function and
    record in a std::vector<> or std::set<> (or some other
    C++ container) the set of basic blocks that you want to change. 
    After you do that, you can iterate through all the basic blocks in
    the container and start making modifications to them.<br>
    <br>
    That will fix any iterator invalidation occurring with the for()
    loop.  That may work, but if I had been writing this pass, I would
    probably have made it a FunctionPass to ensure that the CFG changes
    don't confuse the PassManager.<br>
    <br>
    -- John T.<br>
    <br>
    <blockquote
cite="mid:CAHbEVmT_mY3aUu5LMVvYg6RUgd0SaqhA2RE5wJhzc-RYz0EfQw@mail.gmail.com"
      type="cite"><br>
      <div class="gmail_quote">On Mon, Dec 12, 2011 at 7:54 PM, neda
        8664 <span dir="ltr"><<a moz-do-not-send="true"
            href="mailto:neda8664@gmail.com">neda8664@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 class="MsoNormal">
          </p>
          <p class="MsoNormal">Thank you for your reply</p>
          <p class="MsoNormal">Yes, I change them, <span
              style="text-align:-webkit-auto;word-spacing:0px">so
              what should I do for another loops?</span><span dir="RTL"
style="font-family:"Arial","sans-serif""
              lang="AR-SA"></span></p>
          <div class="HOEnZb">
            <div class="h5">
              <br>
              <div class="gmail_quote">On Mon, Dec 12, 2011 at 7:42 PM,
                John Criswell <span dir="ltr"><<a
                    moz-do-not-send="true"
                    href="mailto:criswell@illinois.edu" target="_blank">criswell@illinois.edu</a>></span>
                wrote:<br>
                <blockquote class="gmail_quote" style="margin:0 0 0
                  .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  <div bgcolor="#FFFFFF" text="#000000">
                    <div> On 12/12/11 9:59 AM, neda 8664 wrote:
                      <blockquote type="cite"> hi all,<br>
                        <br>
                        I want access to all basic blocks of function in
                        a loop, so I used the following code:<br>
                        <br>
                        <font size="1"><i>bool parallel::runOnLoop(Loop
                            *L, LPPassManager &LPM)<br>
                            {<br>
                                for (Function::iterator bi=
                            func->begin(); bi != func->end();
                            bi++){<br>
                                   //<br>
                                 }<br>
                            }</i></font><br>
                      </blockquote>
                      <br>
                    </div>
                    Are you modifying anything within this code
                    (especially changes that add/remove basic blocks or
                    change their Terminator instructions)?  Depending on
                    what you're doing, you may be invalidating the basic
                    block iterator bi.<br>
                    <br>
                    -- John T.<br>
                    <br>
                    <blockquote type="cite">
                      <div><br>
                        First loop run without problem, but for second
                        loop I get the following error:<br>
                        <br>
                        <i><font size="1">0  <a moz-do-not-send="true"
                              href="http://libLLVM-2.9.so"
                              target="_blank">libLLVM-2.9.so</a>
                            0x0137d530<br>
                            1  <a moz-do-not-send="true"
                              href="http://libLLVM-2.9.so"
                              target="_blank">libLLVM-2.9.so</a>
                            0x0137fa6c<br>
                            2                 0x002a7400
                            __kernel_sigreturn + 0<br>
                            3  parallel.so    0x002895e9
                            parallel::runOnLoop(llvm::Loop*,
                            llvm::LPPassManager&) + 345<br>
                            4  <a moz-do-not-send="true"
                              href="http://libLLVM-2.9.so"
                              target="_blank">libLLVM-2.9.so</a>
                            0x00982994
                            llvm::LPPassManager::runOnFunction(llvm::Function&)
                            + 1156<br>
                            5  <a moz-do-not-send="true"
                              href="http://libLLVM-2.9.so"
                              target="_blank">libLLVM-2.9.so</a>
                            0x00eb02c1
                            llvm::FPPassManager::runOnFunction(llvm::Function&)
                            + 545<br>
                            6  <a moz-do-not-send="true"
                              href="http://libLLVM-2.9.so"
                              target="_blank">libLLVM-2.9.so</a>
                            0x00eb03d7
                            llvm::FPPassManager::runOnModule(llvm::Module&)
                            + 87<br>
                            7  <a moz-do-not-send="true"
                              href="http://libLLVM-2.9.so"
                              target="_blank">libLLVM-2.9.so</a>
                            0x00eafde5
                            llvm::MPPassManager::runOnModule(llvm::Module&)
                            + 517<br>
                            8  <a moz-do-not-send="true"
                              href="http://libLLVM-2.9.so"
                              target="_blank">libLLVM-2.9.so</a>
                            0x00eaff8b
                            llvm::PassManagerImpl::run(llvm::Module&)
                            + 171<br>
                            9  <a moz-do-not-send="true"
                              href="http://libLLVM-2.9.so"
                              target="_blank">libLLVM-2.9.so</a>
                            0x00eb008d
                            llvm::PassManager::run(llvm::Module&) +
                            45<br>
                            10 opt            0x0805b32f main + 5295<br>
                            11 libc.so.6      0x002becc6
                            __libc_start_main + 230<br>
                            12 opt            0x0804ff51<br>
                            Stack dump:<br>
                            0.    Program arguments: opt -dse -lda
                            -memdep -basicaa -libcall-aa -scev-aa
                            -globalsmodref-aa -load
                            /home/llvm/src/Release+Debug+Profile+Asserts/lib/parallel.so
                            -parallel -dot-cfg obj.o -o out.o<br>
                            1.    Running pass 'Function Pass Manager'
                            on module 'obj.o'.<br>
                            2.    Running pass 'Loop Pass Manager' on
                            function '@main'<br>
                            3.    Running pass 'parallel World Pass' on
                            basic block '%bb4'<br>
                            Segmentation fault (core dumped)</font></i><br>
                        <br>
                        <fieldset></fieldset>
                        <br>
                      </div>
                      <pre>_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a moz-do-not-send="true" href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a>
<a moz-do-not-send="true" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
                    </blockquote>
                    <br>
                  </div>
                </blockquote>
              </div>
              <br>
            </div>
          </div>
        </blockquote>
      </div>
      <br>
    </blockquote>
    <br>
  </body>
</html>