Tracking global variables accesses

Hello!

Is there any analysis in LLVM that can be used to obtain, for a function, the
list of all global variables that may be modified as a result of a call to
that function (taking into account any calls in those function and aliasing).
If not, what's the best way to implement such a analysis?

Thanks,
Volodya

No, not directly. However, with the standard alias analysis interface, you can query a particular function call to see if it will modify a particular global (to get a list of all globals potentially modified, just iterate through the globals). If your pass uses the standard alias analysis interface, this will allow it to work with many different aa implementations.

The other option is to hack the globals mod/ref alias analysis in Analysis/IPA to do what you want.

-Chris

> Is there any analysis in LLVM that can be used to obtain, for a function,
> the list of all global variables that may be modified as a result of a
> call to that function (taking into account any calls in those function
> and aliasing). If not, what's the best way to implement such a analysis?

No, not directly. However, with the standard alias analysis interface,
you can query a particular function call to see if it will modify a
particular global (to get a list of all globals potentially modified, just
iterate through the globals). If your pass uses the standard alias
analysis interface, this will allow it to work with many different aa
implementations.

So, I can just call AliasAnalysis::getModRefInfo with a call instruction and
global value as argument? Excellent.

The other option is to hack the globals mod/ref alias analysis in
Analysis/IPA to do what you want.

Will that have any advantage over calling getModRefInfo for each global
variable?

- Volodya

iterate through the globals). If your pass uses the standard alias
analysis interface, this will allow it to work with many different aa
implementations.

So, I can just call AliasAnalysis::getModRefInfo with a call instruction and
global value as argument? Excellent.

Yes.

The other option is to hack the globals mod/ref alias analysis in
Analysis/IPA to do what you want.

Will that have any advantage over calling getModRefInfo for each global
variable?

No. Additionally, that would prevent your from using other alias analyses.

-Chris