Page MenuHomePhabricator

[AA] Pass AAResults through AAQueryInfo
Needs ReviewPublic

Authored by nikic on Sat, Jan 9, 1:14 PM.

Details

Summary

Currently, AAResultBase (from which alias analysis passes inherit) stores a reference back to the AAResults aggregation it is part of, so it can perform recursive alias analysis queries via getBestAAResults. This has the implicit assumption that an AAResult can only be part of a single AAResults aggregation. At least under the legacy pass manager, this doesn't seem to actually be the case. This appears to be mostly harmless in practice, but caused quite a bit of confusion for me, and could be dangerous depending on the lifetimes of the objects involved (one could be left with dangling AAResults references).

Instead of storing a reference inside AAResult, this instead passes in the used AAResults aggregation as part of the query. AAQueryInfo offers a convenient way to do this nowadays. Code doing recursive queries just needs to use AAQI.AAR instead of getBestAAResults().

Diff Detail

Event Timeline

nikic created this revision.Sat, Jan 9, 1:14 PM
nikic requested review of this revision.Sat, Jan 9, 1:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptSat, Jan 9, 1:14 PM
nikic added inline comments.Sat, Jan 9, 1:15 PM
llvm/lib/Analysis/BasicAliasAnalysis.cpp
699

This is the only place using getBestAAResults() and not having access to AAQueryInfo yet. If the general approach here is okay, I'll thread through AAQI to this method in a separate commit.

Do you have an idea if there is overhead of adding the AAR object to each query (each query info object)? (vs the setAAResults being done once for all the AAs available).

Details/nits:

  • clang-format
  • if approved, this change would need to go in together with the patch threading AAQI to getModRefBehavior.
llvm/include/llvm/Analysis/AliasAnalysis.h
359

Add comment this stands for Aggregated Alias Result?

Do you have an idea if there is overhead of adding the AAR object to each query (each query info object)? (vs the setAAResults being done once for all the AAs available).

It looks like adding AAR to the query doesn't have noticeable overhead: https://llvm-compile-time-tracker.com/compare.php?from=6ee44ee7c3cee47cb070ccb961359df8de252f36&to=9787880b8fe7ed5f62f15eaeed561a6ce09fdfd6&stat=instructions

There is however a small cost to passing AAQI through getModRefBehavior: https://llvm-compile-time-tracker.com/compare.php?from=33be50daa9ce1074c3b423a4ab27c70c0722113a&to=6ee44ee7c3cee47cb070ccb961359df8de252f36&stat=instructions