mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 04:24:00 +00:00
enhance NonLocalDepEntry to keep the per-block phi translated address
of the query. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90958 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "llvm/BasicBlock.h"
|
#include "llvm/BasicBlock.h"
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
|
#include "llvm/Support/ValueHandle.h"
|
||||||
#include "llvm/ADT/DenseMap.h"
|
#include "llvm/ADT/DenseMap.h"
|
||||||
#include "llvm/ADT/SmallPtrSet.h"
|
#include "llvm/ADT/SmallPtrSet.h"
|
||||||
#include "llvm/ADT/OwningPtr.h"
|
#include "llvm/ADT/OwningPtr.h"
|
||||||
@ -133,19 +134,37 @@ namespace llvm {
|
|||||||
|
|
||||||
/// NonLocalDepEntry - This is an entry in the NonLocalDepInfo cache, and an
|
/// 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
|
/// 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 {
|
class NonLocalDepEntry {
|
||||||
BasicBlock *BB;
|
BasicBlock *BB;
|
||||||
MemDepResult Result;
|
MemDepResult Result;
|
||||||
|
WeakVH Address;
|
||||||
public:
|
public:
|
||||||
NonLocalDepEntry(BasicBlock *bb, MemDepResult result)
|
NonLocalDepEntry(BasicBlock *bb, MemDepResult result, Value *address)
|
||||||
: BB(bb), Result(result) {}
|
: 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.
|
// BB is the sort key, it can't be changed.
|
||||||
BasicBlock *getBB() const { return BB; }
|
BasicBlock *getBB() const { return BB; }
|
||||||
|
|
||||||
|
void setResult(const MemDepResult &R, Value *Addr) {
|
||||||
|
Result = R;
|
||||||
|
Address = Addr;
|
||||||
|
}
|
||||||
|
|
||||||
const MemDepResult &getResult() const { return Result; }
|
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 {
|
bool operator<(const NonLocalDepEntry &RHS) const {
|
||||||
return BB < RHS.BB;
|
return BB < RHS.BB;
|
||||||
|
@ -502,7 +502,7 @@ MemoryDependenceAnalysis::getNonLocalCallDependency(CallSite QueryCS) {
|
|||||||
DEBUG(AssertSorted(Cache, NumSortedEntries));
|
DEBUG(AssertSorted(Cache, NumSortedEntries));
|
||||||
NonLocalDepInfo::iterator Entry =
|
NonLocalDepInfo::iterator Entry =
|
||||||
std::upper_bound(Cache.begin(), Cache.begin()+NumSortedEntries,
|
std::upper_bound(Cache.begin(), Cache.begin()+NumSortedEntries,
|
||||||
NonLocalDepEntry(DirtyBB, MemDepResult()));
|
NonLocalDepEntry(DirtyBB));
|
||||||
if (Entry != Cache.begin() && prior(Entry)->getBB() == DirtyBB)
|
if (Entry != Cache.begin() && prior(Entry)->getBB() == DirtyBB)
|
||||||
--Entry;
|
--Entry;
|
||||||
|
|
||||||
@ -546,9 +546,9 @@ MemoryDependenceAnalysis::getNonLocalCallDependency(CallSite QueryCS) {
|
|||||||
// If we had a dirty entry for the block, update it. Otherwise, just add
|
// If we had a dirty entry for the block, update it. Otherwise, just add
|
||||||
// a new entry.
|
// a new entry.
|
||||||
if (ExistingResult)
|
if (ExistingResult)
|
||||||
ExistingResult->setResult(Dep);
|
ExistingResult->setResult(Dep, 0);
|
||||||
else
|
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
|
// If the block has a dependency (i.e. it isn't completely transparent to
|
||||||
// the value), remember the association!
|
// the value), remember the association!
|
||||||
@ -600,7 +600,8 @@ getNonLocalPointerDependency(Value *Pointer, bool isLoad, BasicBlock *FromBB,
|
|||||||
return;
|
return;
|
||||||
Result.clear();
|
Result.clear();
|
||||||
Result.push_back(NonLocalDepEntry(FromBB,
|
Result.push_back(NonLocalDepEntry(FromBB,
|
||||||
MemDepResult::getClobber(FromBB->begin())));
|
MemDepResult::getClobber(FromBB->begin()),
|
||||||
|
Pointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// GetNonLocalInfoForBlock - Compute the memdep value for BB with
|
/// GetNonLocalInfoForBlock - Compute the memdep value for BB with
|
||||||
@ -616,7 +617,7 @@ GetNonLocalInfoForBlock(Value *Pointer, uint64_t PointeeSize,
|
|||||||
// the cache set. If so, find it.
|
// the cache set. If so, find it.
|
||||||
NonLocalDepInfo::iterator Entry =
|
NonLocalDepInfo::iterator Entry =
|
||||||
std::upper_bound(Cache->begin(), Cache->begin()+NumSortedEntries,
|
std::upper_bound(Cache->begin(), Cache->begin()+NumSortedEntries,
|
||||||
NonLocalDepEntry(BB, MemDepResult()));
|
NonLocalDepEntry(BB));
|
||||||
if (Entry != Cache->begin() && (Entry-1)->getBB() == BB)
|
if (Entry != Cache->begin() && (Entry-1)->getBB() == BB)
|
||||||
--Entry;
|
--Entry;
|
||||||
|
|
||||||
@ -655,9 +656,9 @@ GetNonLocalInfoForBlock(Value *Pointer, uint64_t PointeeSize,
|
|||||||
// If we had a dirty entry for the block, update it. Otherwise, just add
|
// If we had a dirty entry for the block, update it. Otherwise, just add
|
||||||
// a new entry.
|
// a new entry.
|
||||||
if (ExistingResult)
|
if (ExistingResult)
|
||||||
ExistingResult->setResult(Dep);
|
ExistingResult->setResult(Dep, Pointer);
|
||||||
else
|
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
|
// 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
|
// the value), remember the reverse association because we just added it
|
||||||
@ -806,7 +807,7 @@ getNonLocalPointerDepFromBB(const PHITransAddr &Pointer, uint64_t PointeeSize,
|
|||||||
|
|
||||||
// If we got a Def or Clobber, add this to the list of results.
|
// If we got a Def or Clobber, add this to the list of results.
|
||||||
if (!Dep.isNonLocal()) {
|
if (!Dep.isNonLocal()) {
|
||||||
Result.push_back(NonLocalDepEntry(BB, Dep));
|
Result.push_back(NonLocalDepEntry(BB, Dep, Pointer.getAddr()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -889,7 +890,8 @@ getNonLocalPointerDepFromBB(const PHITransAddr &Pointer, uint64_t PointeeSize,
|
|||||||
if (PredPtrVal == 0) {
|
if (PredPtrVal == 0) {
|
||||||
// Add the entry to the Result list.
|
// Add the entry to the Result list.
|
||||||
NonLocalDepEntry Entry(Pred,
|
NonLocalDepEntry Entry(Pred,
|
||||||
MemDepResult::getClobber(Pred->getTerminator()));
|
MemDepResult::getClobber(Pred->getTerminator()),
|
||||||
|
PredPtrVal);
|
||||||
Result.push_back(Entry);
|
Result.push_back(Entry);
|
||||||
|
|
||||||
// Add it to the cache for this CacheKey so that subsequent queries get
|
// Add it to the cache for this CacheKey so that subsequent queries get
|
||||||
@ -909,16 +911,16 @@ getNonLocalPointerDepFromBB(const PHITransAddr &Pointer, uint64_t PointeeSize,
|
|||||||
// noop
|
// noop
|
||||||
} else if (It->getResult().getInst() == Pred->getTerminator()) {
|
} else if (It->getResult().getInst() == Pred->getTerminator()) {
|
||||||
// Same instruction, clear the dirty marker.
|
// Same instruction, clear the dirty marker.
|
||||||
It->setResult(Entry.getResult());
|
It->setResult(Entry.getResult(), PredPtrVal);
|
||||||
} else if (It->getResult().getInst() == 0) {
|
} else if (It->getResult().getInst() == 0) {
|
||||||
// Dirty, with no instruction, just add this.
|
// Dirty, with no instruction, just add this.
|
||||||
It->setResult(Entry.getResult());
|
It->setResult(Entry.getResult(), PredPtrVal);
|
||||||
ReverseNonLocalPtrDeps[Pred->getTerminator()].insert(CacheKey);
|
ReverseNonLocalPtrDeps[Pred->getTerminator()].insert(CacheKey);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, dirty with a different instruction.
|
// Otherwise, dirty with a different instruction.
|
||||||
RemoveFromReverseMap(ReverseNonLocalPtrDeps,
|
RemoveFromReverseMap(ReverseNonLocalPtrDeps,
|
||||||
It->getResult().getInst(), CacheKey);
|
It->getResult().getInst(), CacheKey);
|
||||||
It->setResult(Entry.getResult());
|
It->setResult(Entry.getResult(),PredPtrVal);
|
||||||
ReverseNonLocalPtrDeps[Pred->getTerminator()].insert(CacheKey);
|
ReverseNonLocalPtrDeps[Pred->getTerminator()].insert(CacheKey);
|
||||||
}
|
}
|
||||||
Cache = 0;
|
Cache = 0;
|
||||||
@ -981,7 +983,7 @@ getNonLocalPointerDepFromBB(const PHITransAddr &Pointer, uint64_t PointeeSize,
|
|||||||
|
|
||||||
assert(I->getResult().isNonLocal() &&
|
assert(I->getResult().isNonLocal() &&
|
||||||
"Should only be here with transparent block");
|
"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);
|
ReverseNonLocalPtrDeps[BB->begin()].insert(CacheKey);
|
||||||
Result.push_back(*I);
|
Result.push_back(*I);
|
||||||
break;
|
break;
|
||||||
@ -1137,7 +1139,7 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction *RemInst) {
|
|||||||
if (DI->getResult().getInst() != RemInst) continue;
|
if (DI->getResult().getInst() != RemInst) continue;
|
||||||
|
|
||||||
// Convert to a dirty entry for the subsequent instruction.
|
// Convert to a dirty entry for the subsequent instruction.
|
||||||
DI->setResult(NewDirtyVal);
|
DI->setResult(NewDirtyVal, DI->getAddress());
|
||||||
|
|
||||||
if (Instruction *NextI = NewDirtyVal.getInst())
|
if (Instruction *NextI = NewDirtyVal.getInst())
|
||||||
ReverseDepsToAdd.push_back(std::make_pair(NextI, *I));
|
ReverseDepsToAdd.push_back(std::make_pair(NextI, *I));
|
||||||
@ -1179,7 +1181,7 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction *RemInst) {
|
|||||||
if (DI->getResult().getInst() != RemInst) continue;
|
if (DI->getResult().getInst() != RemInst) continue;
|
||||||
|
|
||||||
// Convert to a dirty entry for the subsequent instruction.
|
// Convert to a dirty entry for the subsequent instruction.
|
||||||
DI->setResult(NewDirtyVal);
|
DI->setResult(NewDirtyVal, DI->getAddress());
|
||||||
|
|
||||||
if (Instruction *NewDirtyInst = NewDirtyVal.getInst())
|
if (Instruction *NewDirtyInst = NewDirtyVal.getInst())
|
||||||
ReversePtrDepsToAdd.push_back(std::make_pair(NewDirtyInst, P));
|
ReversePtrDepsToAdd.push_back(std::make_pair(NewDirtyInst, P));
|
||||||
|
Reference in New Issue
Block a user