diff options
author | Owen Anderson <resistor@mac.com> | 2009-10-28 06:18:42 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-10-28 06:18:42 +0000 |
commit | 4bc737c5ef120e27834b92a86939331f370ba49c (patch) | |
tree | 8d43f7fee9ec55ac6d9bdd4020a8907c3aeff778 /lib/Analysis/MemoryDependenceAnalysis.cpp | |
parent | 50b136dae90eb37f9fc9517a8638020db4f04f9c (diff) |
Add trivial support for the invariance intrinsics to memdep. This logic is
purely local for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85378 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r-- | lib/Analysis/MemoryDependenceAnalysis.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index a071205a12..edead091ed 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -171,13 +171,42 @@ getCallSiteDependencyFrom(CallSite CS, bool isReadOnlyCall, /// location depends. If isLoad is true, this routine ignore may-aliases with /// read-only operations. MemDepResult MemoryDependenceAnalysis:: -getPointerDependencyFrom(Value *MemPtr, uint64_t MemSize, bool isLoad, +getPointerDependencyFrom(Value *MemPtr, uint64_t MemSize, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB) { + Value* invariantTag = 0; + // Walk backwards through the basic block, looking for dependencies. while (ScanIt != BB->begin()) { Instruction *Inst = --ScanIt; + // If we're in an invariant region, no dependencies can be found before + // we pass an invariant-begin marker. + if (invariantTag == Inst) { + invariantTag = 0; + continue; + + // If we pass an invariant-end marker, then we've just entered an invariant + // region and can start ignoring dependencies. + } else if (IntrinsicInst* II = dyn_cast<IntrinsicInst>(Inst)) { + if (II->getIntrinsicID() == Intrinsic::invariant_end) { + uint64_t invariantSize = ~0ULL; + if (ConstantInt* CI = dyn_cast<ConstantInt>(II->getOperand(2))) + invariantSize = CI->getZExtValue(); + + AliasAnalysis::AliasResult R = + AA->alias(II->getOperand(3), invariantSize, MemPtr, MemSize); + if (R == AliasAnalysis::MustAlias) { + invariantTag = II->getOperand(1); + continue; + } + } + } + + // If we're querying on a load and we're in an invariant region, we're done + // at this point. Nothing a load depends on can live in an invariant region. + if (isLoad && invariantTag) continue; + // Debug intrinsics don't cause dependences. if (isa<DbgInfoIntrinsic>(Inst)) continue; @@ -201,6 +230,11 @@ getPointerDependencyFrom(Value *MemPtr, uint64_t MemSize, bool isLoad, return MemDepResult::getDef(Inst); } + // If we're querying on a store and we're in an invariant region, we're done + // at this point. The only things that stores depend on that could exist in + // an invariant region are loads, which we've already checked. + if (invariantTag) continue; + if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) { // If alias analysis can tell that this store is guaranteed to not modify // the query pointer, ignore it. Use getModRefInfo to handle cases where |