From e7122e58a1ce2459c97f07ba499a451d315c8cd5 Mon Sep 17 00:00:00 2001 From: Daniel Berlin Date: Mon, 13 Apr 2015 23:20:13 +0000 Subject: [PATCH] Common some code from MemoryDependenceAnalysis that will be used in MemorySSA git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234813 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/AliasAnalysis.h | 13 +++++++++++++ lib/Analysis/MemoryDependenceAnalysis.cpp | 18 +----------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/include/llvm/Analysis/AliasAnalysis.h b/include/llvm/Analysis/AliasAnalysis.h index 9ce394c0984..d6ea91e2f13 100644 --- a/include/llvm/Analysis/AliasAnalysis.h +++ b/include/llvm/Analysis/AliasAnalysis.h @@ -145,6 +145,19 @@ public: Location getLocation(const AtomicRMWInst *RMWI); static Location getLocationForSource(const MemTransferInst *MTI); static Location getLocationForDest(const MemIntrinsic *MI); + Location getLocation(const Instruction *Inst) { + if (auto *I = dyn_cast(Inst)) + return getLocation(I); + else if (auto *I = dyn_cast(Inst)) + return getLocation(I); + else if (auto *I = dyn_cast(Inst)) + return getLocation(I); + else if (auto *I = dyn_cast(Inst)) + return getLocation(I); + else if (auto *I = dyn_cast(Inst)) + return getLocation(I); + llvm_unreachable("unsupported memory instruction"); + } /// Alias analysis result - Either we know for sure that it does not alias, we /// know for sure it must alias, or we don't know anything: The two pointers diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index a7add7bfef3..84769cb07d7 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -874,23 +874,7 @@ MemoryDependenceAnalysis::getNonLocalCallDependency(CallSite QueryCS) { void MemoryDependenceAnalysis:: getNonLocalPointerDependency(Instruction *QueryInst, SmallVectorImpl &Result) { - - auto getLocation = [](AliasAnalysis *AA, Instruction *Inst) { - if (auto *I = dyn_cast(Inst)) - return AA->getLocation(I); - else if (auto *I = dyn_cast(Inst)) - return AA->getLocation(I); - else if (auto *I = dyn_cast(Inst)) - return AA->getLocation(I); - else if (auto *I = dyn_cast(Inst)) - return AA->getLocation(I); - else if (auto *I = dyn_cast(Inst)) - return AA->getLocation(I); - else - llvm_unreachable("unsupported memory instruction"); - }; - - const AliasAnalysis::Location Loc = getLocation(AA, QueryInst); + const AliasAnalysis::Location Loc = AA->getLocation(QueryInst); bool isLoad = isa(QueryInst); BasicBlock *FromBB = QueryInst->getParent(); assert(FromBB); -- 2.34.1