[llvm] r248462 - BasicAA: Move BasicAAResult::alias out-of-line. NFC
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 23 21:59:26 PDT 2015
Author: bogner
Date: Wed Sep 23 23:59:24 2015
New Revision: 248462
URL: http://llvm.org/viewvc/llvm-project?rev=248462&view=rev
Log:
BasicAA: Move BasicAAResult::alias out-of-line. NFC
This makes the header more readable and cleans up some unnecessary
header differences between NDEBUG and !NDEBUG.
Modified:
llvm/trunk/include/llvm/Analysis/BasicAliasAnalysis.h
llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
Modified: llvm/trunk/include/llvm/Analysis/BasicAliasAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/BasicAliasAnalysis.h?rev=248462&r1=248461&r2=248462&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/BasicAliasAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/BasicAliasAnalysis.h Wed Sep 23 23:59:24 2015
@@ -44,26 +44,6 @@ class BasicAAResult : public AAResultBas
DominatorTree *DT;
LoopInfo *LI;
-#ifndef NDEBUG
- static const Function *getParent(const Value *V) {
- if (const Instruction *inst = dyn_cast<Instruction>(V))
- return inst->getParent()->getParent();
-
- if (const Argument *arg = dyn_cast<Argument>(V))
- return arg->getParent();
-
- return nullptr;
- }
-
- static bool notDifferentParent(const Value *O1, const Value *O2) {
-
- const Function *F1 = getParent(O1);
- const Function *F2 = getParent(O2);
-
- return !F1 || !F2 || F1 == F2;
- }
-#endif
-
public:
BasicAAResult(const DataLayout &DL, const TargetLibraryInfo &TLI,
AssumptionCache &AC, DominatorTree *DT = nullptr,
@@ -81,27 +61,7 @@ public:
/// By definition, this result is stateless and so remains valid.
bool invalidate(Function &, const PreservedAnalyses &) { return false; }
- AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
- assert(notDifferentParent(LocA.Ptr, LocB.Ptr) &&
- "BasicAliasAnalysis doesn't support interprocedural queries.");
-
- // 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 = AliasCache.find(LocPair(LocA, LocB));
- if (CacheIt != AliasCache.end())
- return CacheIt->second;
-
- AliasResult Alias = aliasCheck(LocA.Ptr, LocA.Size, LocA.AATags, LocB.Ptr,
- LocB.Size, LocB.AATags);
- // AliasCache rarely has more than 1 or 2 elements, always use
- // shrink_and_clear so it quickly returns to the inline capacity of the
- // SmallDenseMap if it ever grows larger.
- // FIXME: This should really be shrink_to_inline_capacity_and_clear().
- AliasCache.shrink_and_clear();
- VisitedPhiBBs.clear();
- return Alias;
- }
+ AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc);
Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=248462&r1=248461&r2=248462&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Wed Sep 23 23:59:24 2015
@@ -627,6 +627,47 @@ static bool isAssumeIntrinsic(ImmutableC
return false;
}
+static const Function *getParent(const Value *V) {
+ if (const Instruction *inst = dyn_cast<Instruction>(V))
+ return inst->getParent()->getParent();
+
+ if (const Argument *arg = dyn_cast<Argument>(V))
+ return arg->getParent();
+
+ return nullptr;
+}
+
+static bool notDifferentParent(const Value *O1, const Value *O2) {
+
+ const Function *F1 = getParent(O1);
+ const Function *F2 = getParent(O2);
+
+ return !F1 || !F2 || F1 == F2;
+}
+
+AliasResult BasicAAResult::alias(const MemoryLocation &LocA,
+ const MemoryLocation &LocB) {
+ assert(notDifferentParent(LocA.Ptr, LocB.Ptr) &&
+ "BasicAliasAnalysis doesn't support interprocedural queries.");
+
+ // 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 = AliasCache.find(LocPair(LocA, LocB));
+ if (CacheIt != AliasCache.end())
+ return CacheIt->second;
+
+ AliasResult Alias = aliasCheck(LocA.Ptr, LocA.Size, LocA.AATags, LocB.Ptr,
+ LocB.Size, LocB.AATags);
+ // AliasCache rarely has more than 1 or 2 elements, always use
+ // shrink_and_clear so it quickly returns to the inline capacity of the
+ // SmallDenseMap if it ever grows larger.
+ // FIXME: This should really be shrink_to_inline_capacity_and_clear().
+ AliasCache.shrink_and_clear();
+ VisitedPhiBBs.clear();
+ return Alias;
+}
+
/// Checks to see if the specified callsite can clobber the specified memory
/// object.
///
More information about the llvm-commits
mailing list