<br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Ryan Taylor</b> <span dir="ltr"><<a href="mailto:ryta1203@gmail.com">ryta1203@gmail.com</a>></span><br>Date: Mon, Nov 21, 2011 at 10:30 AM<br>
Subject: Re: [LLVMdev] Order of Basic Blocks<br>To: Benjamin Kramer <<a href="mailto:benny.kra@googlemail.com">benny.kra@googlemail.com</a>><br><br><br>This worked, though the RPO_iterator apparently wasn't what I was looking for anyways, it seems it doesn't rreally go top->down.<br>
<br>I have a simple example code, where the block follow this path:<br><br>BB0->BB1 (T), BB8 (F)<br>
BB1-> BB2 (T), BB3 (F)<br>BB2-> BB4<br>BB3-> BB5<br>BB4-> BB6<br>BB5-> BB8 (T), BB5 (F)<br>BB6-> BB7 (T), BB4 (F)<br>BB7-> BB8 (T), BB4 (F)<br>BB8 (end)<br><br>So, this is the basic block flow graph. When I iterate using the ReversePostOrderTraversal iterator, the basic blocks vistied are in this order:<br>

<br>BB0, BB1, BB3, BB2, BB7, BB6, BB4, BB5, BB8<br><br>Can someone explain why this is and how the BBs are stored so that I can either go top->down or more prefably, depth first search (from the given graph above)?<br>

<br>Thanks.<div class="HOEnZb"><div class="h5"><br><br><br><div class="gmail_quote">On Mon, Nov 21, 2011 at 10:14 AM, Benjamin Kramer <span dir="ltr"><<a href="mailto:benny.kra@googlemail.com" target="_blank">benny.kra@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><br>
On 21.11.2011, at 19:07, Ryan Taylor wrote:<br>
<br>
> 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.<br>
<br>
</div>Dereference it.<br>
<br>
- Ben<br>
<div><div><br>
<br>
><br>
> On Sun, Nov 20, 2011 at 3:15 PM, Ryan Taylor <<a href="mailto:ryta1203@gmail.com" target="_blank">ryta1203@gmail.com</a>> wrote:<br>
> Sorry, forgot to add group to CC.<br>
><br>
> On Sun, Nov 20, 2011 at 6:14 PM, Ryan Taylor <<a href="mailto:ryta1203@gmail.com" target="_blank">ryta1203@gmail.com</a>> wrote:<br>
> Cameron,<br>
><br>
>   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.<br>
><br>
>   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?<br>


><br>
> On Sun, Nov 20, 2011 at 6:10 PM, Cameron Zwarich <<a href="mailto:zwarich@apple.com" target="_blank">zwarich@apple.com</a>> wrote:<br>
> Your question is a bit vague, but you probably want ReversePostOrderTraversal from include/llvm/ADT/PostOrderIterator.h.<br>
><br>
> Cameron<br>
><br>
> On Nov 20, 2011, at 3:00 PM, Ryan Taylor wrote:<br>
><br>
> > LLVMers,<br>
> ><br>
> >   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?<br>


> ><br>
> > Thank you.<br>
> > _______________________________________________<br>
> > LLVM Developers mailing list<br>
> > <a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
><br>
><br>
><br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br>
</div></div></blockquote></div><br>
</div></div></div><br>