[LLVMdev] Depth First Sort of Machine Basic Blocks just before emitting code

Chris Lattner clattner at apple.com
Mon Apr 13 11:35:09 PDT 2009


On Apr 13, 2009, at 11:20 AM, Daniel M Gessel wrote:

> For nefarious reasons I won't go into (this is for a quick hack that
> will be thrown away in a week or two), I'd like my Asm printer to get
> MBBs in a depth first order.
>
> Is there an existing pass or function that will let me do this easily?

Check out "llvm/ADT/DepthFirstIterator.h", it lets you iterate over  
arbitrary graphs (including CFGs) in depth first order.  grep the  
source base for df_begin etc to see examples of use.

-Chris



More information about the llvm-dev mailing list