[llvm-commits] [llvm] r60266 - in /llvm/trunk: include/llvm/Analysis/MemoryDependenceAnalysis.h lib/Analysis/MemoryDependenceAnalysis.cpp
Chris Lattner
sabre at nondot.org
Sat Nov 29 17:26:32 PST 2008
Author: lattner
Date: Sat Nov 29 19:26:32 2008
New Revision: 60266
URL: http://llvm.org/viewvc/llvm-project?rev=60266&view=rev
Log:
implement a fixme by introducing a new getDependencyFromInternal
method that returns its result as a DepResultTy instead of as a
MemDepResult. This reduces conversion back and forth.
Modified:
llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h
llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
Modified: llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h?rev=60266&r1=60265&r2=60266&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h Sat Nov 29 19:26:32 2008
@@ -170,8 +170,13 @@
/// getDependencyFrom - Return the instruction on which the memory operation
/// 'QueryInst' depends. This starts scanning from the instruction before
/// the position indicated by ScanIt.
+ ///
+ /// Note that this method does no caching at all. You should use
+ /// getDependency where possible.
MemDepResult getDependencyFrom(Instruction *QueryInst,
- BasicBlock::iterator ScanIt, BasicBlock *BB);
+ BasicBlock::iterator ScanIt, BasicBlock *BB){
+ return ConvToResult(getDependencyFromInternal(QueryInst, ScanIt, BB));
+ }
/// getNonLocalDependency - Perform a full dependency query for the
@@ -190,15 +195,6 @@
void removeInstruction(Instruction *InstToRemove);
private:
- DepResultTy ConvFromResult(MemDepResult R) {
- if (Instruction *I = R.getInst())
- return DepResultTy(I, Normal);
- if (R.isNonLocal())
- return DepResultTy(0, NonLocal);
- assert(R.isNone() && "Unknown MemDepResult!");
- return DepResultTy(0, None);
- }
-
MemDepResult ConvToResult(DepResultTy R) {
if (R.getInt() == Normal)
return MemDepResult::get(R.getPointer());
@@ -212,8 +208,13 @@
/// in our internal data structures.
void verifyRemoved(Instruction *Inst) const;
- MemDepResult getCallSiteDependency(CallSite C, BasicBlock::iterator ScanIt,
- BasicBlock *BB);
+ /// getDependencyFromInternal - Return the instruction on which the memory
+ /// operation 'QueryInst' depends. This starts scanning from the
+ /// instruction before the position indicated by ScanIt.
+ DepResultTy getDependencyFromInternal(Instruction *QueryInst,
+ BasicBlock::iterator ScanIt, BasicBlock *BB);
+ DepResultTy getCallSiteDependency(CallSite C, BasicBlock::iterator ScanIt,
+ BasicBlock *BB);
};
} // End llvm namespace
Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=60266&r1=60265&r2=60266&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Sat Nov 29 19:26:32 2008
@@ -47,7 +47,7 @@
/// getCallSiteDependency - Private helper for finding the local dependencies
/// of a call site.
-MemDepResult MemoryDependenceAnalysis::
+MemoryDependenceAnalysis::DepResultTy MemoryDependenceAnalysis::
getCallSiteDependency(CallSite C, BasicBlock::iterator ScanIt,
BasicBlock *BB) {
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
@@ -84,24 +84,24 @@
if (AA.getModRefBehavior(CallSite::get(Inst)) ==
AliasAnalysis::DoesNotAccessMemory)
continue;
- return MemDepResult::get(Inst);
+ return DepResultTy(Inst, Normal);
} else
continue;
if (AA.getModRefInfo(C, Pointer, PointerSize) != AliasAnalysis::NoModRef)
- return MemDepResult::get(Inst);
+ return DepResultTy(Inst, Normal);
}
// No dependence found.
- return MemDepResult::getNonLocal();
+ return DepResultTy(0, NonLocal);
}
/// getDependency - Return the instruction on which a memory operation
/// depends. The local parameter indicates if the query should only
/// evaluate dependencies within the same basic block.
-MemDepResult MemoryDependenceAnalysis::
-getDependencyFrom(Instruction *QueryInst, BasicBlock::iterator ScanIt,
- BasicBlock *BB) {
+MemoryDependenceAnalysis::DepResultTy MemoryDependenceAnalysis::
+getDependencyFromInternal(Instruction *QueryInst, BasicBlock::iterator ScanIt,
+ BasicBlock *BB) {
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
TargetData &TD = getAnalysis<TargetData>();
@@ -128,7 +128,7 @@
} else if (isa<CallInst>(QueryInst) || isa<InvokeInst>(QueryInst))
return getCallSiteDependency(CallSite::get(QueryInst), ScanIt, BB);
else // Non-memory instructions depend on nothing.
- return MemDepResult::getNone();
+ return DepResultTy(0, None);
// Walk backwards through the basic block, looking for dependencies
while (ScanIt != BB->begin()) {
@@ -139,7 +139,7 @@
if (MemVolatile &&
((isa<LoadInst>(Inst) && cast<LoadInst>(Inst)->isVolatile()) ||
(isa<StoreInst>(Inst) && cast<StoreInst>(Inst)->isVolatile())))
- return MemDepResult::get(Inst);
+ return DepResultTy(Inst, Normal);
// MemDep is broken w.r.t. loads: it says that two loads of the same pointer
// depend on each other. :(
@@ -157,7 +157,7 @@
// May-alias loads don't depend on each other without a dependence.
if (isa<LoadInst>(QueryInst) && R == AliasAnalysis::MayAlias)
continue;
- return MemDepResult::get(Inst);
+ return DepResultTy(Inst, Normal);
}
// FIXME: This claims that an access depends on the allocation. This may
@@ -179,7 +179,7 @@
if (R == AliasAnalysis::NoAlias)
continue;
- return MemDepResult::get(Inst);
+ return DepResultTy(Inst, Normal);
}
@@ -194,11 +194,11 @@
continue;
// Otherwise, there is a dependence.
- return MemDepResult::get(Inst);
+ return DepResultTy(Inst, Normal);
}
// If we found nothing, return the non-local flag.
- return MemDepResult::getNonLocal();
+ return DepResultTy(0, NonLocal);
}
/// getDependency - Return the instruction on which a memory operation
@@ -220,16 +220,14 @@
ScanPos = Inst;
// Do the scan.
- MemDepResult Res =
- getDependencyFrom(QueryInst, ScanPos, QueryInst->getParent());
+ LocalCache = getDependencyFromInternal(QueryInst, ScanPos,
+ QueryInst->getParent());
// Remember the result!
- // FIXME: Don't convert back and forth! Make a shared helper function.
- LocalCache = ConvFromResult(Res);
- if (Instruction *I = Res.getInst())
+ if (Instruction *I = LocalCache.getPointer())
ReverseLocalDeps[I].insert(QueryInst);
- return Res;
+ return ConvToResult(LocalCache);
}
/// getNonLocalDependency - Perform a full dependency query for the
@@ -287,17 +285,14 @@
// If DirtyBBEntry isn't dirty, it ended up on the worklist multiple times.
if (DirtyBBEntry.getInt() != Dirty) continue;
- // Find out if this block has a local dependency for QueryInst.
- // FIXME: Don't convert back and forth for MemDepResult <-> DepResultTy.
-
// If the dirty entry has a pointer, start scanning from it so we don't have
// to rescan the entire block.
BasicBlock::iterator ScanPos = DirtyBB->end();
if (Instruction *Inst = DirtyBBEntry.getPointer())
ScanPos = Inst;
- DirtyBBEntry = ConvFromResult(getDependencyFrom(QueryInst, ScanPos,
- DirtyBB));
+ // Find out if this block has a local dependency for QueryInst.
+ DirtyBBEntry = getDependencyFromInternal(QueryInst, ScanPos, DirtyBB);
// If the block has a dependency (i.e. it isn't completely transparent to
// the value), remember it!
More information about the llvm-commits
mailing list