[LLVMdev] Basic Block code sample

Andrew Clinton andrew at sidefx.com
Tue Mar 19 09:05:25 PDT 2013


To get definitions before uses (apart from PHI nodes), use 
ReversePostOrderTraversal:

#include <llvm/ADT/PostOrderIterator.h>

ReversePostOrderTraversal<Function*> rpot((Function *)&func);
for (ReversePostOrderTraversal<Function*>::rpo_iterator bi =
             rpot.begin(), be = rpot.end(); bi != be; ++bi)
{
     (*bi)->dump();
}

On 03/19/2013 10:46 AM, Alexandru Ionut Diaconescu wrote:
> Hi,
>
> Example on how to iterate over CFG, take a look at 
> |DominanceFrontier.cpp|.
>
> You can further implement easily a traverse graph algorithm.
>
> On Tue, Mar 19, 2013 at 2:35 PM, Ashish Kulkarni 
> <ashish-kulkarni at hotmail.com <mailto:ashish-kulkarni at hotmail.com>> wrote:
>
>     Hi LLVM Delveloper,
>            i've been working on LLVM and Clang to get basic block
>     information. The CFG supports Visitors (CFG.h) but i might want to
>     ask thatis there any code sample available so that i can get the
>     things easily..
>
>     Regards,
>     Kulkarni Ashish A.
>     College of engineering, Pune
>     India.
>
>     _______________________________________________
>     LLVM Developers mailing list
>     LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu>
>     http://llvm.cs.uiuc.edu
>     http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
>
>
> -- 
> Best regards,
> Alexandru Ionut Diaconescu
>
>
> _______________________________________________
> 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/20130319/5f7aa154/attachment.html>


More information about the llvm-dev mailing list