Is it possible to get dependency variable?
I'm trying to build my program analysis on top of dg (llvm-dg-dump), what I need is to retrieve the variable name of a given data dependency.
For example, let's say that I have an statement S_0 that read %x and %y, and dg finds a dependency to an statement S_1 that stores %z (because %z may be an alias of %x). My question is how do I find that %x is the responsible variable of the dependency between S_0 and S_1?
Is this possible to retrieve this information from the dg source code?
if not, at which point does it get lost from the analysis?
Cheers
Are you interested in the top-level (register) variables, or do you want to get the memory allocations that were written/read?
I think that register llvm variables would be enough to my purpose. Are them easy to get?
Easier would be to get the memory allocations, but you can probably get also the variables. If you have S_0 = load A and S_1 = store B to C, then you want to get the points-to sets of A and C and find out their intersection. This intersection is the memory that (may) have been written and consequently read by S_1 and S_0. A and C are the aliased pointers, so you can derive that these pointers are aliases to the memory allocations (with some offset that makes the read/write overlap). Of course, there may be also the pointer "unknown".
Okay, any insights of which method should I use in the code to get the variables of the statement and the points-to set? Given that I already know the label of the two statements.
Yes, try using LLVMPointerAnalysis::getLLVMPointsTo or LLVMPointerAnalysis::getLLVMPointsToChecked defined in dg/llvm/analysis/PointsTo/PointerAnalysis.h (so it should be callable on the PTA object from the builder.