[llvm-commits] [llvm] r90958 - in /llvm/trunk: include/llvm/Analysis/MemoryDependenceAnalysis.h lib/Analysis/MemoryDependenceAnalysis.cpp
Chris Lattner
sabre at nondot.org
Tue Dec 8 23:31:04 PST 2009
Author: lattner
Date: Wed Dec 9 01:31:04 2009
New Revision: 90958
URL: http://llvm.org/viewvc/llvm-project?rev=90958&view=rev
Log:
enhance NonLocalDepEntry to keep the per-block phi translated address
of the query.
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=90958&r1=90957&r2=90958&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h Wed Dec 9 01:31:04 2009
@@ -16,6 +16,7 @@
#include "llvm/BasicBlock.h"
#include "llvm/Pass.h"
+#include "llvm/Support/ValueHandle.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/OwningPtr.h"
@@ -133,20 +134,38 @@
/// NonLocalDepEntry - This is an entry in the NonLocalDepInfo cache, and an
/// entry in the results set for a non-local query. For each BasicBlock (the
- /// BB entry) it keeps a MemDepResult.
+ /// BB entry) it keeps a MemDepResult and the (potentially phi translated)
+ /// address that was live in the block.
class NonLocalDepEntry {
BasicBlock *BB;
MemDepResult Result;
+ WeakVH Address;
public:
- NonLocalDepEntry(BasicBlock *bb, MemDepResult result)
- : BB(bb), Result(result) {}
-
+ NonLocalDepEntry(BasicBlock *bb, MemDepResult result, Value *address)
+ : BB(bb), Result(result), Address(address) {}
+
+ // This is used for searches.
+ NonLocalDepEntry(BasicBlock *bb) : BB(bb) {}
+
// BB is the sort key, it can't be changed.
BasicBlock *getBB() const { return BB; }
+ void setResult(const MemDepResult &R, Value *Addr) {
+ Result = R;
+ Address = Addr;
+ }
+
const MemDepResult &getResult() const { return Result; }
- void setResult(const MemDepResult &R) { Result = R; }
+ /// getAddress - Return the address of this pointer in this block. This can
+ /// be different than the address queried for the non-local result because
+ /// of phi translation. This returns null if the address was not available
+ /// in a block (i.e. because phi translation failed) or if this is a cached
+ /// result and that address was deleted.
+ ///
+ /// The address is always null for a non-local 'call' dependence.
+ Value *getAddress() const { return Address; }
+
bool operator<(const NonLocalDepEntry &RHS) const {
return BB < RHS.BB;
}
Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=90958&r1=90957&r2=90958&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Wed Dec 9 01:31:04 2009
@@ -502,7 +502,7 @@
DEBUG(AssertSorted(Cache, NumSortedEntries));
NonLocalDepInfo::iterator Entry =
std::upper_bound(Cache.begin(), Cache.begin()+NumSortedEntries,
- NonLocalDepEntry(DirtyBB, MemDepResult()));
+ NonLocalDepEntry(DirtyBB));
if (Entry != Cache.begin() && prior(Entry)->getBB() == DirtyBB)
--Entry;
@@ -546,9 +546,9 @@
// If we had a dirty entry for the block, update it. Otherwise, just add
// a new entry.
if (ExistingResult)
- ExistingResult->setResult(Dep);
+ ExistingResult->setResult(Dep, 0);
else
- Cache.push_back(NonLocalDepEntry(DirtyBB, Dep));
+ Cache.push_back(NonLocalDepEntry(DirtyBB, Dep, 0));
// If the block has a dependency (i.e. it isn't completely transparent to
// the value), remember the association!
@@ -600,7 +600,8 @@
return;
Result.clear();
Result.push_back(NonLocalDepEntry(FromBB,
- MemDepResult::getClobber(FromBB->begin())));
+ MemDepResult::getClobber(FromBB->begin()),
+ Pointer));
}
/// GetNonLocalInfoForBlock - Compute the memdep value for BB with
@@ -616,7 +617,7 @@
// the cache set. If so, find it.
NonLocalDepInfo::iterator Entry =
std::upper_bound(Cache->begin(), Cache->begin()+NumSortedEntries,
- NonLocalDepEntry(BB, MemDepResult()));
+ NonLocalDepEntry(BB));
if (Entry != Cache->begin() && (Entry-1)->getBB() == BB)
--Entry;
@@ -655,9 +656,9 @@
// If we had a dirty entry for the block, update it. Otherwise, just add
// a new entry.
if (ExistingResult)
- ExistingResult->setResult(Dep);
+ ExistingResult->setResult(Dep, Pointer);
else
- Cache->push_back(NonLocalDepEntry(BB, Dep));
+ Cache->push_back(NonLocalDepEntry(BB, Dep, Pointer));
// If the block has a dependency (i.e. it isn't completely transparent to
// the value), remember the reverse association because we just added it
@@ -806,7 +807,7 @@
// If we got a Def or Clobber, add this to the list of results.
if (!Dep.isNonLocal()) {
- Result.push_back(NonLocalDepEntry(BB, Dep));
+ Result.push_back(NonLocalDepEntry(BB, Dep, Pointer.getAddr()));
continue;
}
}
@@ -889,7 +890,8 @@
if (PredPtrVal == 0) {
// Add the entry to the Result list.
NonLocalDepEntry Entry(Pred,
- MemDepResult::getClobber(Pred->getTerminator()));
+ MemDepResult::getClobber(Pred->getTerminator()),
+ PredPtrVal);
Result.push_back(Entry);
// Add it to the cache for this CacheKey so that subsequent queries get
@@ -909,16 +911,16 @@
// noop
} else if (It->getResult().getInst() == Pred->getTerminator()) {
// Same instruction, clear the dirty marker.
- It->setResult(Entry.getResult());
+ It->setResult(Entry.getResult(), PredPtrVal);
} else if (It->getResult().getInst() == 0) {
// Dirty, with no instruction, just add this.
- It->setResult(Entry.getResult());
+ It->setResult(Entry.getResult(), PredPtrVal);
ReverseNonLocalPtrDeps[Pred->getTerminator()].insert(CacheKey);
} else {
// Otherwise, dirty with a different instruction.
RemoveFromReverseMap(ReverseNonLocalPtrDeps,
It->getResult().getInst(), CacheKey);
- It->setResult(Entry.getResult());
+ It->setResult(Entry.getResult(),PredPtrVal);
ReverseNonLocalPtrDeps[Pred->getTerminator()].insert(CacheKey);
}
Cache = 0;
@@ -981,7 +983,7 @@
assert(I->getResult().isNonLocal() &&
"Should only be here with transparent block");
- I->setResult(MemDepResult::getClobber(BB->begin()));
+ I->setResult(MemDepResult::getClobber(BB->begin()), Pointer.getAddr());
ReverseNonLocalPtrDeps[BB->begin()].insert(CacheKey);
Result.push_back(*I);
break;
@@ -1137,7 +1139,7 @@
if (DI->getResult().getInst() != RemInst) continue;
// Convert to a dirty entry for the subsequent instruction.
- DI->setResult(NewDirtyVal);
+ DI->setResult(NewDirtyVal, DI->getAddress());
if (Instruction *NextI = NewDirtyVal.getInst())
ReverseDepsToAdd.push_back(std::make_pair(NextI, *I));
@@ -1179,7 +1181,7 @@
if (DI->getResult().getInst() != RemInst) continue;
// Convert to a dirty entry for the subsequent instruction.
- DI->setResult(NewDirtyVal);
+ DI->setResult(NewDirtyVal, DI->getAddress());
if (Instruction *NewDirtyInst = NewDirtyVal.getInst())
ReversePtrDepsToAdd.push_back(std::make_pair(NewDirtyInst, P));
More information about the llvm-commits
mailing list