[cfe-dev] Analyzing the AST for variable usage
Vedant Kumar via cfe-dev
cfe-dev at lists.llvm.org
Wed Sep 9 15:14:00 PDT 2015
Hi Nat,
I'm not sure something like this exists. If I were to try it, I'd start by writing a llvm::FunctionPass which uses the alias analyzer. There's some documentation on this here:
http://llvm.org/docs/AliasAnalysis.html#using-alias-analysis-results
In your example, it seems like you'd like to check if any loads/stores in your function may alias with 'p'.
vedant
> On Sep 9, 2015, at 1:05 PM, Nat! via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>
> Hi
>
> before I am writing this myself, I just wonder, if this functionality is maybe available somewhere (analyzer ?).
>
> I want to know for every AST node, in a function, if any successor nodes access a memory area, that has been passed in by a (single) argument.
>
> Or less abstract
>
> ---
> struct foo
> {
> char space[ 20];
> };
>
>
> extern int whatever( char *);
>
>
> void f( struct foo *p)
> {
> char *q;
> char tmp[ 10];
>
> q = &p->space[ 10];
> loop:
> whatever( q);
> if( whatever( tmp))
> goto loop;
>
> // here comes the first node, that does not touch p space
>
> whatever( tmp);
> }
> ---
>
>
> Ciao
> Nat!
>
> P.S. For my purposes it's really better do this on clang level than on llvm level.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list