Generating DFG or CDFG from C code

Hi All,


I am new to LLVM. I want to generate a Dataflow graph or Control Dataflow graph from C code using LLVM. I have no idea how to do it in LLVM. I tried to use analysis and transform passes such as “-dot-cfg” but it doesn’t give what I want. I want to generate a node for each operation in C code.


Thanks in advance.
JM.


|

Hi All,
I am reposting my question again since i think my question was not clear enough.
I am wondering is it possible to generate Control Data Flow Graph from C using LLVM? or is it possible to get web-like structure of C code using llvm /

Thanks in advance,
Any comment suggestion would be appreciated.

Jan Ma.

I don’t know if anyone has already done this, but some important pieces are there. See Dataflow.h and GraphWriter.h.

I think you’ll run into a problem though because the value graph isn’t fully connected. You have to walk the instruction stream looking for “roots”.

-Andy

Hi Andrew,
Thanks for the response. That helps a lot.

So that means I have to implement a pass, right ? Sorry for dumb question. I just started LLVM today.

Unless someone else responds with “I’ve already done that” then you need to implement a pass. It’s probably something you want to customize to your needs anyway.
-Andy

Thanks you so much Andrew.
That helps.