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;
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;
std::vector<AnalysisKey *> AADeps;
- /// Query depth used to distinguish recursive queries.
- unsigned Depth = 0;
-
friend class BatchAAResults;
};
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)
// 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(