Extracting Basic Blocks/CFG from LLVM/clang

Hi LLVM developers,

I’ve been beginning to work with LLVM and I’m interested to know if there is a programmatic way to extract the control flow graph and/or basic blocks from LLVM/clang in order to do some analysis on them. Is there a way to get that ?

thank you in advance.


Kulkarni Ashish A.
College of Engineering, Pune

Hi Ashish,

I guess it will easier to answer the question if you provide some more details about what exactly you want to achieve. You can write an LLVM pass to visit all basic blocks and dump them to a file ( if thats what you want) - See [1].

[1]. http://llvm.org/docs/WritingAnLLVMPass.html