1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[AA] Move Depth member from AAResults to AAQI (NFC)

Rather than storing the query depth in AAResults, store it in AAQI.
This makes more sense, as it is a property of the query. This
sidesteps the issue of D94363, fixing slightly inaccurate AA
statistics. Additionally, I plan to use the Depth from BasicAA in
the future, where fetching it from AAResults would be unreliable.

This change is not quite as straightforward as it seems, because
we need to preserve the depth when creating a new AAQI for recursive
queries across phis. I'm adding a new method for this, as we may
need to preserve additional information here in the future.
This commit is contained in:
Nikita Popov 2021-02-12 15:41:22 +01:00
parent 525e98279b
commit f6693f56a5
3 changed files with 16 additions and 7 deletions

View File

@ -360,6 +360,9 @@ public:
using IsCapturedCacheT = SmallDenseMap<const Value *, bool, 8>;
IsCapturedCacheT IsCapturedCache;
/// Query depth used to distinguish recursive queries.
unsigned Depth = 0;
/// How many active NoAlias assumption uses there are.
int NumAssumptionUses = 0;
@ -369,6 +372,15 @@ public:
SmallVector<AAQueryInfo::LocPair, 4> AssumptionBasedResults;
AAQueryInfo() : AliasCache(), IsCapturedCache() {}
/// Create a new AAQueryInfo based on this one, but with the cache cleared.
/// This is used for recursive queries across phis, where cache results may
/// not be valid.
AAQueryInfo withEmptyCache() {
AAQueryInfo NewAAQI;
NewAAQI.Depth = Depth;
return NewAAQI;
}
};
class BatchAAResults;
@ -797,9 +809,6 @@ private:
std::vector<AnalysisKey *> AADeps;
/// Query depth used to distinguish recursive queries.
unsigned Depth = 0;
friend class BatchAAResults;
};

View File

@ -118,15 +118,15 @@ AliasResult AAResults::alias(const MemoryLocation &LocA,
const MemoryLocation &LocB, AAQueryInfo &AAQI) {
AliasResult Result = MayAlias;
Depth++;
AAQI.Depth++;
for (const auto &AA : AAs) {
Result = AA->alias(LocA, LocB, AAQI);
if (Result != MayAlias)
break;
}
Depth--;
AAQI.Depth--;
if (Depth == 0) {
if (AAQI.Depth == 0) {
if (Result == NoAlias)
++NumNoAlias;
else if (Result == MustAlias)

View File

@ -1456,7 +1456,7 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
// If we inserted a block into VisitedPhiBBs, alias analysis results that
// have been cached earlier may no longer be valid. Perform recursive queries
// with a new AAQueryInfo.
AAQueryInfo NewAAQI;
AAQueryInfo NewAAQI = AAQI.withEmptyCache();
AAQueryInfo *UseAAQI = BlockInserted ? &NewAAQI : &AAQI;
AliasResult Alias = getBestAAResults().alias(