[llvm] 1a7a9ef - [BasicAA] Avoid duplicate cache lookup (NFCI)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 24 01:19:15 PDT 2020


Author: Nikita Popov
Date: 2020-10-24T10:19:02+02:00
New Revision: 1a7a9efec3cf872dcf3e1a6e6fe39e797c4d9fc6

URL: https://github.com/llvm/llvm-project/commit/1a7a9efec3cf872dcf3e1a6e6fe39e797c4d9fc6
DIFF: https://github.com/llvm/llvm-project/commit/1a7a9efec3cf872dcf3e1a6e6fe39e797c4d9fc6.diff

LOG: [BasicAA] Avoid duplicate cache lookup (NFCI)

Rather than performing the cache lookup with both possible orders
for the locations, use the same canonicalization as the other
AliasCache lookups in BasicAA.

Added: 
    

Modified: 
    llvm/lib/Analysis/BasicAliasAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 49695bfca38c..5de34c57f9a7 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -804,11 +804,10 @@ AliasResult BasicAAResult::alias(const MemoryLocation &LocA,
   // If we have a directly cached entry for these locations, we have recursed
   // through this once, so just return the cached results. Notably, when this
   // happens, we don't clear the cache.
-  auto CacheIt = AAQI.AliasCache.find(AAQueryInfo::LocPair(LocA, LocB));
-  if (CacheIt != AAQI.AliasCache.end())
-    return CacheIt->second;
-
-  CacheIt = AAQI.AliasCache.find(AAQueryInfo::LocPair(LocB, LocA));
+  AAQueryInfo::LocPair Locs(LocA, LocB);
+  if (Locs.first.Ptr > Locs.second.Ptr)
+    std::swap(Locs.first, Locs.second);
+  auto CacheIt = AAQI.AliasCache.find(Locs);
   if (CacheIt != AAQI.AliasCache.end())
     return CacheIt->second;
 


        


More information about the llvm-commits mailing list