[LLVMdev] problem with llvm reverse iterator

Jakub Staszak kubastaszak at gmail.com
Sat Nov 13 05:39:32 PST 2010


Hi,

You should write sth like this:
for (MachineFunction::iterator MBBI = mf_->end(), E = mf_->begin();MBBI !=
E; ) {
  MachineBasicBlock *MBB = --MBBI;
  DEBUG(dbgs()<<*MBB<<"\n");
}

Regads
-- 
Jakub Staszak

On Sat, Nov 13, 2010 at 2:09 PM, Deepanjana Deb
<deepanjana.deb at gmail.com> wrote:
> Hi,
>
> I am writing an llvm pass wherein I require to iterate MachineBasicBlocks in
> reverse. The ilist reverse_iterator is not functioning as expected. Nor is
> the ilist iterator working
> in reverse (although -- operator is overloaded to do so).
>
> for (MachineFunction::iterator MBBI = mf_->end(), E = mf_->begin();MBBI !=
> E; --MBBI)
>     {
>         MachineBasicBlock *MBB = MBBI;
>         DEBUG(dbgs()<<*MBB<<"\n");
>     }
>
> Any suggestion would be helpful.
>
> Thanks.
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>




More information about the llvm-dev mailing list