<html><head><base href="x-msg://79/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>The reverse postorder iterator does what you want. It's defined in ADT/PostOrderIterator.h, and is used like this:</div><div><div><br></div><div>  ReversePostOrderTraversal<Function*> RPOT(&F);</div><div>  for (ReversePostOrderTraversal<Function*>::rpo_iterator RI = RPOT.begin(),</div><div>       RE = RPOT.end(); RI != RE; ++RI)</div></div><div>    <work here></div><div><br></div><div>Creating a ReversePostOrderTraversal is not cheap, because it first has to do a postorder walk of the entire graph.</div><div><br></div><div>Cameron</div><br><div><div>On Nov 23, 2010, at 9:21 PM, Villmow, Micah wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple"><div class="WordSection1" style="page: WordSection1; "><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; ">I’m looking for a way to traverse machine basic blocks in a specific order.<o:p></o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; ">Basically I want all blocks that are predecessors to the current block to be traversed before the current block.  I’ve looked at MachineDominatorTree but this doesn’t traverse them in quite the way I want them to. Anyone know of a way to do this?<o:p></o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; ">Thanks,<o:p></o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; ">Micah<o:p></o:p></div></div>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" style="color: blue; text-decoration: underline; ">LLVMdev@cs.uiuc.edu</a><span class="Apple-converted-space"> </span>        <a href="http://llvm.cs.uiuc.edu" style="color: blue; text-decoration: underline; ">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" style="color: blue; text-decoration: underline; ">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></div></blockquote></div><br></body></html>