[llvm-dev] Could I do some control-flow and dataflow analysis cross files and functions via IR

Mehdi Amini via llvm-dev llvm-dev at lists.llvm.org
Thu Jan 21 12:44:06 PST 2016


> On Jan 21, 2016, at 12:33 PM, Kevin Hu via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hi Shulin,
> 
> It seems to me what you'll need is your own inter-procedural analysis to deal with data-flow between functions. That is, you'll need to figure out the callgraph between all the functions and the dataflow inside all the functions. In this case, you'll need to find where foo is called (probably multiple places), what are the use cases for all this callsites in the dataflow in foo's parent function, and all the functions where the pointer a's content could be modified. If there're other pointers pointing to the same address a's pointing to, you may also need pointer analysis, where things could get really tricky.
> 
> To deal with different IR files, you'll either have to implement an LTO pass, or use llvm-link to link multiple IRs to a combined IR for analysis run it through your OPT pass like a regular IR.

Just note on this last aspect of the problem: I don’t see any fundamental reason a custom interprocedural-analysis can’t run over a call graph involving functions defined in multiple modules without linking them in a single IR. This is admittedly more involved though.

— 
Mehdi

> 
> Regards,
> Kevin
> 
> On Thu, Jan 21, 2016 at 2:21 AM 周书林 via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
> As mentioned in the title, I want to do some control-flow and dataflow analysis. I can only find the assignment statement in a function, but the assigned variable is just a parameter of this function.
> For example,
> ****************************************
> int foo(struct A* a, int b, ...){
>     ...
>     a->Int_field = b;
>     ...
>     return 0;
> }
> *****************************************
> in the code above, I want to do some analysis for struct A* a's Int_field, but in this function, it is only assigned, I want to find its  Use scenario and fetch some constraints about it.
> So, could I achieve this goal via IR?
> Thanks a lot!
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160121/832a5179/attachment.html>


More information about the llvm-dev mailing list