[cfe-dev] Question about LLVM dependence graph
John Criswell
criswell at illinois.edu
Thu Oct 31 07:42:47 PDT 2013
On 10/31/13 8:42 AM, Feng Lu wrote:
> 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?
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:
http://llvm.org/doxygen/classllvm_1_1Value.html.
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.
> Thanks,
> Feng Lu
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131031/abc480f6/attachment.html>
More information about the cfe-dev
mailing list