Data flow analysis

Hi all,

in this case:


int* p = …
int* q = p;

How can I know that data-flow from p to q,
i.e., which LLVM pass of header files could I use?

Thank you all.

hi,

Hi all,
in this case:
...
int* p = ...
int* q = p;

This will be eliminated by the "mem2reg" pass.

...
How can I know that data-flow from p to q,
i.e., which LLVM pass of header files could I use?

If you want something about "data-flow", there is a header named
"DataFlow.h": http://llvm.org/doxygen/DataFlow_8h.html

best regards
ether

Hi all,

in this case:


int* p = …
int* q = p;

How can I know that data-flow from p to q,
i.e., which LLVM pass of header files could I use?

It’s not completely clear what sort of analysis you want. If you want reaching definitions for just SSA virtual register values, then you only need to follow the explicit def-use chains in the SSA graph (see the use_iterator of class llvm::Value, IIRC).

If you need to know if p and q point to the same memory object (assuming that the memory object is not eliminated by the mem2reg pass), then you need to either use the AliasAnalysis analysis group or a points-to analysis like DSA.

If you need reaching definitions analysis for all values (including those that travel into/out of memory objects), then you need a points-to analysis combined with a reaching definitions analysis. I do not think anyone has implemented such an analysis for LLVM yet, although a (relatively) simple one could probably be written on top of DSA.

– John T.