[LLVMdev] A way to traverse machine basic blocks in order?

Cameron Zwarich zwarich at apple.com
Tue Nov 23 18:33:53 PST 2010


The reverse postorder iterator does what you want. It's defined in ADT/PostOrderIterator.h, and is used like this:

  ReversePostOrderTraversal<Function*> RPOT(&F);
  for (ReversePostOrderTraversal<Function*>::rpo_iterator RI = RPOT.begin(),
       RE = RPOT.end(); RI != RE; ++RI)
    <work here>

Creating a ReversePostOrderTraversal is not cheap, because it first has to do a postorder walk of the entire graph.

Cameron

On Nov 23, 2010, at 9:21 PM, Villmow, Micah wrote:

> I’m looking for a way to traverse machine basic blocks in a specific order.
> 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?
>  
> Thanks,
> Micah
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101123/611a96da/attachment.html>


More information about the llvm-dev mailing list