Reputation: 523
I would like to know if there is any existing tools that can construct a data dependence graph, starting from an assembly piece of code?
My objective is: starting from a set of assembly instructions (resulting from compiled C code using GCC/LLVM), construct a dependence graph, that would help analyze how each variable contributes to the final result.
Any suggestions of what I could learn about in order to achieve this? Can existing compilers output something like that or an intermediate representation that I can transform graphically?
E.g. if we consider a simple addition D = (A + B)*C
, such as the following :
load R1, Address_of_A
load R2, Address_of_B
load R3, Address_of_C
add R4, R1, R2
mul R5, R4, R3
store R5, Address_of_D
The result could be something like:
A ----
(+)------
B ---- |--------
(*)----> D
C ----------------------
Upvotes: 2
Views: 1217
Reputation: 21878
There are numerous tools for this on Github. I suggest looking at miasm, the code is in Python and is extremely readable. Dataflow construction is in data_flow.py.
Upvotes: 1