How to obtain CFG using llvm-gcc?


llvm-gcc is deprecated. It would be wise to avoid using it unless you have to!

You don't say what form you want the control flow graphs in. AFAIK you
can think of LLVM bitcode modules (emitted by using -emit-llvm flag)
as a collection of global variables and functions. Each function is
essentially a control flow graph. You can quickly take a look at a CFG
by doing something like...

clang -emit-llvm -c hello.c -o hello.bc
opt -analyze -view-cfg hello.bc

Hope that helps,

Dan Liew.