Question about LLVM dependence graph

Hi, all,
I am new to LLVM and Clang,
I am interested in the following problem:
Given a function with parameters, obtain the part of parameters which are used in branch conditions within the function or sub-functions.

For the following example, I hope to get v.c1
struct p {
int c1,
int c2
};
void foo (p v) {
if (v.c1)

else

}

Does LLVM or Clang contains the code that could easily achieve this efficiently?

Thanks,
Feng Lu

For scalar function arguments, you can just follow the explict def-use chains in the LLVM IR. See the Value::use_begin() and Value::use_end() methods in the doxygen documentation: . For values that live in or escape into memory, the problem is trickier: you need to do classical Kam-Ullman data flow analysis (specifically, reaching definitions analysis), and you’ll need to deal with aliasing of pointers. LLVM does not currently have an analysis for this, as far as I know. Of course, all of this gets even more complicated if you’re doing it inter-procedurally or want to take into account external library code. – John T.