CFG extraction

Hello,

I would like to extract Control Flow Graph and Data Flow Graph from a sample program written in C++, Can anybody please direct me to some examples?
Thanks in advance

|

I know the MachineBasicBlock has some nice predecessor and successor iterators. See MachineBasicBlock::pred_iterator and MachineBasicBlock::succ_iterator for those iterators.

-Jeff Kunkel

Hi,

to get the CFG's use this command.

clang++ -S -emit-llvm program.cpp
opt -view-cfg program.s

This needs the graphviz package to be installed as the dotty program is called.

To just extract the dot files of the CFG use:

opt -dot-cfg program.s

If you use -dot-cfg-only -view-cfg-only the CFG does not contain the statements of each bb.

I do not know if there is any DataFlowGraph available in LLVM.

Cheers
Tobi