Common some code from MemoryDependenceAnalysis that will be used in MemorySSA

llvm-svn: 234813
This commit is contained in:
Daniel Berlin 2015-04-13 23:20:13 +00:00
parent 56b1d00484
commit b8a4d41327
2 changed files with 14 additions and 17 deletions

View File

@ -145,6 +145,19 @@ public:
Location getLocation(const AtomicRMWInst *RMWI); Location getLocation(const AtomicRMWInst *RMWI);
static Location getLocationForSource(const MemTransferInst *MTI); static Location getLocationForSource(const MemTransferInst *MTI);
static Location getLocationForDest(const MemIntrinsic *MI); static Location getLocationForDest(const MemIntrinsic *MI);
Location getLocation(const Instruction *Inst) {
if (auto *I = dyn_cast<LoadInst>(Inst))
return getLocation(I);
else if (auto *I = dyn_cast<StoreInst>(Inst))
return getLocation(I);
else if (auto *I = dyn_cast<VAArgInst>(Inst))
return getLocation(I);
else if (auto *I = dyn_cast<AtomicCmpXchgInst>(Inst))
return getLocation(I);
else if (auto *I = dyn_cast<AtomicRMWInst>(Inst))
return getLocation(I);
llvm_unreachable("unsupported memory instruction");
}
/// Alias analysis result - Either we know for sure that it does not alias, we /// 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 /// know for sure it must alias, or we don't know anything: The two pointers

View File

@ -874,23 +874,7 @@ MemoryDependenceAnalysis::getNonLocalCallDependency(CallSite QueryCS) {
void MemoryDependenceAnalysis:: void MemoryDependenceAnalysis::
getNonLocalPointerDependency(Instruction *QueryInst, getNonLocalPointerDependency(Instruction *QueryInst,
SmallVectorImpl<NonLocalDepResult> &Result) { SmallVectorImpl<NonLocalDepResult> &Result) {
const AliasAnalysis::Location Loc = AA->getLocation(QueryInst);
auto getLocation = [](AliasAnalysis *AA, Instruction *Inst) {
if (auto *I = dyn_cast<LoadInst>(Inst))
return AA->getLocation(I);
else if (auto *I = dyn_cast<StoreInst>(Inst))
return AA->getLocation(I);
else if (auto *I = dyn_cast<VAArgInst>(Inst))
return AA->getLocation(I);
else if (auto *I = dyn_cast<AtomicCmpXchgInst>(Inst))
return AA->getLocation(I);
else if (auto *I = dyn_cast<AtomicRMWInst>(Inst))
return AA->getLocation(I);
else
llvm_unreachable("unsupported memory instruction");
};
const AliasAnalysis::Location Loc = getLocation(AA, QueryInst);
bool isLoad = isa<LoadInst>(QueryInst); bool isLoad = isa<LoadInst>(QueryInst);
BasicBlock *FromBB = QueryInst->getParent(); BasicBlock *FromBB = QueryInst->getParent();
assert(FromBB); assert(FromBB);