From: Chris Lattner Date: Tue, 9 Dec 2008 19:38:05 +0000 (+0000) Subject: rename getNonLocalDependency -> getNonLocalCallDependency, and remove X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=1559b3625be7b80bee6b066af4b91b9d10dfb5fa;p=oota-llvm.git 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 --- diff --git a/include/llvm/Analysis/MemoryDependenceAnalysis.h b/include/llvm/Analysis/MemoryDependenceAnalysis.h index f408423b22b..d7b1fbf8b60 100644 --- a/include/llvm/Analysis/MemoryDependenceAnalysis.h +++ b/include/llvm/Analysis/MemoryDependenceAnalysis.h @@ -215,8 +215,8 @@ namespace llvm { /// this on non-memory instructions. MemDepResult getDependency(Instruction *QueryInst); - /// 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. /// @@ -227,7 +227,7 @@ namespace llvm { /// 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 NonLocalDepInfo &getNonLocalDependency(Instruction *QueryInst); + const NonLocalDepInfo &getNonLocalCallDependency(CallSite QueryCS); /// getNonLocalPointerDependency - Perform a full dependency query for an diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index 30d54505d1b..cd63c0fc52c 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(QueryInst) || isa(QueryInst) || - isa(QueryInst) || isa(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(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(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(QueryInst) || isa(QueryInst)); - Dep = getCallSiteDependencyFrom(CallSite::get(QueryInst), ScanPos, - DirtyBB); + Dep = MemDepResult::getClobber(ScanPos); } - if (MemPtr) - Dep = getPointerDependencyFrom(MemPtr, MemSize, isa(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 diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index ec300fafb05..79a0fc24e30 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -490,7 +490,7 @@ uint32_t ValueTable::lookup_or_add(Value* V) { // Non-local case. const MemoryDependenceAnalysis::NonLocalDepInfo &deps = - MD->getNonLocalDependency(C); + MD->getNonLocalCallDependency(CallSite(C)); // FIXME: call/call dependencies for readonly calls should return def, not // clobber! Move the checking logic to MemDep! CallInst* cdep = 0;