[BasicAA] Avoid unnecessary cache update (NFC)
authorNikita Popov <nikita.ppv@gmail.com>
Sun, 22 Nov 2020 19:09:56 +0000 (20:09 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Sun, 22 Nov 2020 19:10:45 +0000 (20:10 +0100)
If the final recursive query returns MayAlias as well, there is
no need to update the cache (which already stores MayAlias).

llvm/lib/Analysis/BasicAliasAnalysis.cpp

index cfc1c59..16043da 100644 (file)
@@ -1785,7 +1785,11 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
   // memory locations. We have already ensured that BasicAA has a MayAlias
   // cache result for these, so any recursion back into BasicAA won't loop.
   AliasResult Result = getBestAAResults().alias(Locs.first, Locs.second, AAQI);
-  return AAQI.updateResult(Locs, Result);
+  if (Result != MayAlias)
+    return AAQI.updateResult(Locs, Result);
+
+  // MayAlias is already in the cache.
+  return MayAlias;
 }
 
 /// Check whether two Values can be considered equivalent.