diff options
author | Chris Lattner <sabre@nondot.org> | 2008-12-09 19:38:05 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-12-09 19:38:05 +0000 |
commit | 1559b3625be7b80bee6b066af4b91b9d10dfb5fa (patch) | |
tree | a9166685ae8d512b5c420af13770e270d317fc05 /lib/Analysis/MemoryDependenceAnalysis.cpp | |
parent | 91bcf6450ab063204a7ccd933d7db40028485147 (diff) |
rename getNonLocalDependency -> getNonLocalCallDependency, and remove
pointer stuff from it, simplifying the code a bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60783 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r-- | lib/Analysis/MemoryDependenceAnalysis.cpp | 70 |
1 files changed, 22 insertions, 48 deletions
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index 30d54505d1..cd63c0fc52 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -304,22 +304,23 @@ MemDepResult MemoryDependenceAnalysis::getDependency(Instruction *QueryInst) { return LocalCache; } -/// getNonLocalDependency - Perform a full dependency query for the -/// specified instruction, returning the set of blocks that the value is +/// getNonLocalCallDependency - Perform a full dependency query for the +/// specified call, returning the set of blocks that the value is /// potentially live across. The returned set of results will include a /// "NonLocal" result for all blocks where the value is live across. /// -/// This method assumes the instruction returns a "nonlocal" dependency +/// This method assumes the instruction returns a "NonLocal" dependency /// within its own block. /// +/// This returns a reference to an internal data structure that may be +/// invalidated on the next non-local query or when an instruction is +/// removed. Clients must copy this data if they want it around longer than +/// that. const MemoryDependenceAnalysis::NonLocalDepInfo & -MemoryDependenceAnalysis::getNonLocalDependency(Instruction *QueryInst) { - // FIXME: Make this only be for callsites in the future. - assert(isa<CallInst>(QueryInst) || isa<InvokeInst>(QueryInst) || - isa<LoadInst>(QueryInst) || isa<StoreInst>(QueryInst)); - assert(getDependency(QueryInst).isNonLocal() && - "getNonLocalDependency should only be used on insts with non-local deps!"); - PerInstNLInfo &CacheP = NonLocalDeps[QueryInst]; +MemoryDependenceAnalysis::getNonLocalCallDependency(CallSite QueryCS) { + assert(getDependency(QueryCS.getInstruction()).isNonLocal() && + "getNonLocalCallDependency should only be used on calls with non-local deps!"); + PerInstNLInfo &CacheP = NonLocalDeps[QueryCS.getInstruction()]; NonLocalDepInfo &Cache = CacheP.first; /// DirtyBlocks - This is the set of blocks that need to be recomputed. In @@ -351,7 +352,7 @@ MemoryDependenceAnalysis::getNonLocalDependency(Instruction *QueryInst) { // << Cache.size() << " cached: " << *QueryInst; } else { // Seed DirtyBlocks with each of the preds of QueryInst's block. - BasicBlock *QueryBB = QueryInst->getParent(); + BasicBlock *QueryBB = QueryCS.getInstruction()->getParent(); for (BasicBlock **PI = PredCache->GetPreds(QueryBB); *PI; ++PI) DirtyBlocks.push_back(*PI); NumUncacheNonLocal++; @@ -398,51 +399,24 @@ MemoryDependenceAnalysis::getNonLocalDependency(Instruction *QueryInst) { if (Instruction *Inst = ExistingResult->getInst()) { ScanPos = Inst; // We're removing QueryInst's use of Inst. - RemoveFromReverseMap(ReverseNonLocalDeps, Inst, QueryInst); + RemoveFromReverseMap(ReverseNonLocalDeps, Inst, + QueryCS.getInstruction()); } } // Find out if this block has a local dependency for QueryInst. MemDepResult Dep; - Value *MemPtr = 0; - uint64_t MemSize = 0; - - if (ScanPos == DirtyBB->begin()) { - // No dependence found. If this is the entry block of the function, it is a - // clobber, otherwise it is non-local. - if (DirtyBB != &DirtyBB->getParent()->getEntryBlock()) - Dep = MemDepResult::getNonLocal(); - else - Dep = MemDepResult::getClobber(ScanPos); - } else if (StoreInst *SI = dyn_cast<StoreInst>(QueryInst)) { - // If this is a volatile store, don't mess around with it. Just return the - // previous instruction as a clobber. - if (SI->isVolatile()) - Dep = MemDepResult::getClobber(--BasicBlock::iterator(ScanPos)); - else { - MemPtr = SI->getPointerOperand(); - MemSize = TD->getTypeStoreSize(SI->getOperand(0)->getType()); - } - } else if (LoadInst *LI = dyn_cast<LoadInst>(QueryInst)) { - // If this is a volatile load, don't mess around with it. Just return the - // previous instruction as a clobber. - if (LI->isVolatile()) - Dep = MemDepResult::getClobber(--BasicBlock::iterator(ScanPos)); - else { - MemPtr = LI->getPointerOperand(); - MemSize = TD->getTypeStoreSize(LI->getType()); - } + if (ScanPos != DirtyBB->begin()) { + Dep = getCallSiteDependencyFrom(QueryCS, ScanPos, DirtyBB); + } else if (DirtyBB != &DirtyBB->getParent()->getEntryBlock()) { + // No dependence found. If this is the entry block of the function, it is + // a clobber, otherwise it is non-local. + Dep = MemDepResult::getNonLocal(); } else { - assert(isa<CallInst>(QueryInst) || isa<InvokeInst>(QueryInst)); - Dep = getCallSiteDependencyFrom(CallSite::get(QueryInst), ScanPos, - DirtyBB); + Dep = MemDepResult::getClobber(ScanPos); } - if (MemPtr) - Dep = getPointerDependencyFrom(MemPtr, MemSize, isa<LoadInst>(QueryInst), - ScanPos, DirtyBB); - // If we had a dirty entry for the block, update it. Otherwise, just add // a new entry. if (ExistingResult) @@ -456,7 +430,7 @@ MemoryDependenceAnalysis::getNonLocalDependency(Instruction *QueryInst) { // Keep the ReverseNonLocalDeps map up to date so we can efficiently // update this when we remove instructions. if (Instruction *Inst = Dep.getInst()) - ReverseNonLocalDeps[Inst].insert(QueryInst); + ReverseNonLocalDeps[Inst].insert(QueryCS.getInstruction()); } else { // If the block *is* completely transparent to the load, we need to check |