[LLVMdev] "Best" alias analysis algorithm

Vladimir Prus ghost at cs.msu.su
Mon Apr 25 23:27:37 PDT 2005

On Monday 25 April 2005 23:40, Chris Lattner wrote:
> On Mon, 25 Apr 2005, Vladimir Prus wrote:
> > The GlobalsModRef::getModRefInfo has this logic:
> >
> >    // If we are asking for mod/ref info of a direct call with a pointer
> > to a // global we are tracking, return information if we have it.
> >    if (GlobalValue *GV =
> > const_cast<GlobalValue*>(getUnderlyingObject(P))) if
> > (GV->hasInternalLinkage())
> >
> > So, no information is produced for external variables, the function calls
> > Aliasanalysis::getModRefInfo, which sees that called function may write
> > to memory, and returns true for all global variables.
> >
> > Anything I can do about it? What I what is minimally accurate information
> > about all global variables a function may modify. "Modifies them all" is
> > clearly not even minimally accurate.
> Oh ok, now I remember.  The deal here is that "globals-modref" is supposed
> to be a very simple mod/ref analysis that does no "pointer analysis" at
> all.  In particular, it only tracks globals that it knows "never have
> their address taken".  If a global has non-internal linkage, the compiler
> can't know that something outside of the program doesn't take its address
> and pass around its address.

Even if something outside of the current module has the address of the global, 
it cannot modify that global, because the control never leaves the current 
module, no?

> While in this case, globals modref could handle this case, you really want
> something more powerful like -ds-aa.

I'm missed -ds-aa in the list of passes and now tried it. Seems to work fine 
even when variables are declared external. Thanks!

- Volodya

More information about the llvm-dev mailing list