[LLVMdev] Program order in inst_iterator?

Tobias Edler von Koch tobias at codeaurora.org
Tue Jun 16 12:10:43 PDT 2015


On Tue, 16 Jun 2015 13:53:49 -0500 John Criswell <jtcriswel at gmail.com>
wrote:

> > Thanks for these responses. So, in summary, if I need a particular
> > order when visiting instructions or basic blocks, I need to do it
> > myself, without relying on the LLVM API to guarantee it.
> 
> Existing LLVM passes may help (e.g., DominatorTree can help iterate over 
> basic blocks so that you see definitions before uses, phi-nodes 
> notwithstanding), but generally speaking, yes.

There's also scc_iterator which lets you do a postorder traversal of
SCCs in the CFG.

Check out Eli's blog post about this:

http://eli.thegreenplace.net/2013/09/16/analyzing-function-cfgs-with-llvm

Tobias

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
Linux Foundation Collaborative Project.



More information about the llvm-dev mailing list