get basic blocks inside a machine code loop

Hello everyone,
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.
I wrote my code like this:

MachineLoopInfo &MLI = getAnalysis();
for (MachineLoopInfo::iterator i = MLI.begin(), e = MLI.end(); i != e; ++i) {
MachineLoop *ML = *i;
int bbCounter = 0;
loopCounter++;
for(MachineLoop::iterator mbb = ML->begin(); mbb != ML->end(); ++mbb) {
bbCounter+=1;
}
errs() <<“bbcounter” << bbCounter << “\n”;

}
errs() << “loopCounter” << loopCounter << “\n”;

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.
It means that my iterator on machineloop does not work. I appreciate any help with this problem.
Thanks,
Fami

MachineLoop is a subclass of LoopBase, which is a template and defines getBlocks for the specified block type.

-Krzysztof