<div dir="ltr">Hello everyone,<div>I am trying to write a pass which works on machine instructions. I need to get all basic blocks in the loop. I could't find any function like getblocks for machineloop.</div><div>I wrote my code like this:</div><div><br></div><div><div>MachineLoopInfo &MLI = getAnalysis<MachineLoopInfo>();</div><div>for (MachineLoopInfo::iterator i = MLI.begin(), e = MLI.end(); i != e; ++i) {</div><div><span class="" style="white-space:pre">   </span>MachineLoop *ML = *i;</div><div><span class="" style="white-space:pre">      </span>int bbCounter = 0;</div><div><span class="" style="white-space:pre"> </span>loopCounter++;</div><div><span class="" style="white-space:pre">     </span>for(MachineLoop::iterator mbb = ML->begin(); mbb != ML->end(); ++mbb) {</div><div><span class="" style="white-space:pre">              </span>bbCounter+=1;<span class="" style="white-space:pre">                             </span></div><div><span class="" style="white-space:pre">   </span>}</div><div><span style="white-space:pre">        </span>errs() <<"bbcounter" << bbCounter << "\n";<span class="" style="white-space:pre">      </span></div></div><div><span class="" style="white-space:pre">}</span></div><div><span class=""><span style="white-space:pre">errs() << "loopCounter" << loopCounter << "\n";        </span><br></span></div><div><span class=""><span style="white-space:pre"><br></span></span></div><div><span style="white-space:pre">I used loopcounter and bbcounter to identify if my pass is working correctly. I run this pass on my test code which has 1 loop with 4 basic blocks. It returns 1 for loopcounter, but the bbcounter is 0.</span></div><div><span style="white-space:pre">It means that my iterator on machineloop does not work. I appreciate any help with this problem.</span></div><div><span style="white-space:pre">Thanks,</span></div><div><span style="white-space:pre">Fami</span></div><div><br></div></div>