[LLVMdev] Order of Basic Blocks

Benjamin Kramer benny.kra at googlemail.com
Mon Nov 21 10:14:47 PST 2011


On 21.11.2011, at 19:07, Ryan Taylor wrote:

> Is there a way to cast the rpo_iterator to a basic block pointer? I need to use the functions of the class Basic Block.

Dereference it.

- Ben


> 
> On Sun, Nov 20, 2011 at 3:15 PM, Ryan Taylor <ryta1203 at gmail.com> wrote:
> Sorry, forgot to add group to CC.
> 
> On Sun, Nov 20, 2011 at 6:14 PM, Ryan Taylor <ryta1203 at gmail.com> wrote:
> Cameron,
>  
>   To make it less vague, I would ideally like to traverse top down. I believe what you suggested is what I want, I will have a look at it.
>  
>   Currently, I am iterating over the BBs in a Function, so Function::iterator BBitr=F->begin(), BBitrE=F->end(); BBitr!=BBitrE;++BBitr, does that help clarify what I'm looking for? With this current iteration method, I seem to sometimes get top down but other times get bottom up and sometimes it starts top down then jumps to the bottom and goes bottom up. Is there a reason for this randomness?
> 
> On Sun, Nov 20, 2011 at 6:10 PM, Cameron Zwarich <zwarich at apple.com> wrote:
> Your question is a bit vague, but you probably want ReversePostOrderTraversal from include/llvm/ADT/PostOrderIterator.h.
> 
> Cameron
> 
> On Nov 20, 2011, at 3:00 PM, Ryan Taylor wrote:
> 
> > LLVMers,
> >
> >   Is there any way to guarantee iteration of the basic blocks from top down or path to path? Currently it looks sort of semi-random, sometimes visiting loop heads first and other times loop tails, is there a way I can visit the BBs top down or path to path?
> >
> > Thank you.
> > _______________________________________________
> > LLVM Developers mailing list
> > LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> 
> 
> 
> 
> _______________________________________________
> 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