[llvm-commits] [PATCH] Optimistically analyse phi cycles in BasicAA

Arnold Schwaighofer arnold.schwaighofer at gmail.com
Wed Nov 21 07:24:13 PST 2012


Also send to list ...

On Wed, Nov 21, 2012 at 3:37 AM, Duncan Sands <baldrick at free.fr> wrote:
>
> what happens if the recursion bails out due to hitting a recursion limit?
> Will the conservatively correct MayAlias be returned in that case?

Yes, because when we hit the limit in the recursion we return MayAlias
from this recursion. This result will be merged with the phi's alias
result, setting the phi to MayAlias.

      AliasResult Alias = NoAlias;
      AliasResult OrigAliasResult = AliasCache[Locs]; // Is MayAlias
if we have never seen this node.
      AliasCache[Locs] = NoAlias;

      for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
        AliasResult ThisAlias =
                     [1]
          aliasCheck(PN->getIncomingValue(i), PNSize, PNTBAAInfo,
                     PN2->getIncomingValueForBlock(PN->getIncomingBlock(i)),
                     V2Size, V2TBAAInfo);
        Alias = MergeAliasResults(ThisAlias, Alias);
        if (Alias == MayAlias)
          break;
      }

      // Reset if speculation failed.
      if (Alias != NoAlias)
        AliasCache[Locs] = OrigAliasResult;

We either process all nodes in the phis' input graph and eventually
see a MayAlias result or we give up early and return MayAlias through
the recursion.
The interesting case when we handle two phi nodes. We assume the phis
to be NoAlias and they are not. Let say we process all inputs
recursively then we eventually will see an input that is MayAlias,
this will be propagate up to the call aliasCheck [1] above, resulting
in the phi to be set to MayAlias.
In the case were we hit the recursion limit this again will happen in
the call to aliasCheck [1] which then returns MayAlias and again the
phis' result will be reset to MayAlias.



More information about the llvm-commits mailing list