mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-07 11:51:13 +00:00
Minor factoring, naming and formatting cleanups.
llvm-svn: 77357
This commit is contained in:
parent
9bfa0c1c3d
commit
aa84e1d9d3
@ -50,9 +50,9 @@ static inline bool IsMemRefInstr(const Value *V) {
|
|||||||
static void GetMemRefInstrs(const Loop *L,
|
static void GetMemRefInstrs(const Loop *L,
|
||||||
SmallVectorImpl<Instruction*> &Memrefs) {
|
SmallVectorImpl<Instruction*> &Memrefs) {
|
||||||
for (Loop::block_iterator b = L->block_begin(), be = L->block_end();
|
for (Loop::block_iterator b = L->block_begin(), be = L->block_end();
|
||||||
b != be; ++b)
|
b != be; ++b)
|
||||||
for (BasicBlock::iterator i = (*b)->begin(), ie = (*b)->end();
|
for (BasicBlock::iterator i = (*b)->begin(), ie = (*b)->end();
|
||||||
i != ie; ++i)
|
i != ie; ++i)
|
||||||
if (IsMemRefInstr(i))
|
if (IsMemRefInstr(i))
|
||||||
Memrefs.push_back(i);
|
Memrefs.push_back(i);
|
||||||
}
|
}
|
||||||
@ -71,6 +71,15 @@ static Value *GetPointerOperand(Value *I) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static AliasAnalysis::AliasResult UnderlyingObjectsAlias(AliasAnalysis *AA,
|
||||||
|
const Value *A,
|
||||||
|
const Value *B) {
|
||||||
|
const Value *aObj = A->getUnderlyingObject();
|
||||||
|
const Value *bObj = B->getUnderlyingObject();
|
||||||
|
return AA->alias(aObj, AA->getTypeStoreSize(aObj->getType()),
|
||||||
|
bObj, AA->getTypeStoreSize(bObj->getType()));
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Dependence Testing
|
// Dependence Testing
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@ -83,19 +92,19 @@ bool LoopDependenceAnalysis::isDependencePair(const Value *A,
|
|||||||
cast<const Instruction>(B)->mayWriteToMemory());
|
cast<const Instruction>(B)->mayWriteToMemory());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoopDependenceAnalysis::findOrInsertDependencePair(Value *X,
|
bool LoopDependenceAnalysis::findOrInsertDependencePair(Value *A,
|
||||||
Value *Y,
|
Value *B,
|
||||||
DependencePair *&P) {
|
DependencePair *&P) {
|
||||||
void *insertPos = 0;
|
void *insertPos = 0;
|
||||||
FoldingSetNodeID id;
|
FoldingSetNodeID id;
|
||||||
id.AddPointer(X);
|
id.AddPointer(A);
|
||||||
id.AddPointer(Y);
|
id.AddPointer(B);
|
||||||
|
|
||||||
P = Pairs.FindNodeOrInsertPos(id, insertPos);
|
P = Pairs.FindNodeOrInsertPos(id, insertPos);
|
||||||
if (P) return true;
|
if (P) return true;
|
||||||
|
|
||||||
P = PairAllocator.Allocate<DependencePair>();
|
P = PairAllocator.Allocate<DependencePair>();
|
||||||
new (P) DependencePair(id, X, Y);
|
new (P) DependencePair(id, A, B);
|
||||||
Pairs.InsertNode(P, insertPos);
|
Pairs.InsertNode(P, insertPos);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -114,28 +123,24 @@ void LoopDependenceAnalysis::analysePair(DependencePair *P) const {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value *aptr = GetPointerOperand(P->A);
|
Value *aPtr = GetPointerOperand(P->A);
|
||||||
Value *bptr = GetPointerOperand(P->B);
|
Value *bPtr = GetPointerOperand(P->B);
|
||||||
const Value *aobj = aptr->getUnderlyingObject();
|
|
||||||
const Value *bobj = bptr->getUnderlyingObject();
|
|
||||||
AliasAnalysis::AliasResult alias = AA->alias(
|
|
||||||
aobj, AA->getTypeStoreSize(aobj->getType()),
|
|
||||||
bobj, AA->getTypeStoreSize(bobj->getType()));
|
|
||||||
|
|
||||||
// We can not analyse objects if we do not know about their aliasing.
|
switch (UnderlyingObjectsAlias(AA, aPtr, bPtr)) {
|
||||||
if (alias == AliasAnalysis::MayAlias) {
|
case AliasAnalysis::MayAlias:
|
||||||
|
// We can not analyse objects if we do not know about their aliasing.
|
||||||
DEBUG(errs() << "---> [?] may alias\n");
|
DEBUG(errs() << "---> [?] may alias\n");
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// If the objects noalias, they are distinct, accesses are independent.
|
case AliasAnalysis::NoAlias:
|
||||||
if (alias == AliasAnalysis::NoAlias) {
|
// If the objects noalias, they are distinct, accesses are independent.
|
||||||
DEBUG(errs() << "---> [I] no alias\n");
|
DEBUG(errs() << "---> [I] no alias\n");
|
||||||
P->Result = Independent;
|
P->Result = Independent;
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: the underlying objects MustAlias, test for dependence
|
case AliasAnalysis::MustAlias:
|
||||||
|
break; // The underlying objects alias, test accesses for dependence.
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG(errs() << "---> [?] cannot analyse\n");
|
DEBUG(errs() << "---> [?] cannot analyse\n");
|
||||||
return;
|
return;
|
||||||
@ -187,14 +192,14 @@ static void PrintLoopInfo(raw_ostream &OS,
|
|||||||
|
|
||||||
OS << " Load/store instructions: " << memrefs.size() << "\n";
|
OS << " Load/store instructions: " << memrefs.size() << "\n";
|
||||||
for (SmallVector<Instruction*, 8>::const_iterator x = memrefs.begin(),
|
for (SmallVector<Instruction*, 8>::const_iterator x = memrefs.begin(),
|
||||||
end = memrefs.end(); x != end; ++x)
|
end = memrefs.end(); x != end; ++x)
|
||||||
OS << "\t" << (x - memrefs.begin()) << ": " << **x << "\n";
|
OS << "\t" << (x - memrefs.begin()) << ": " << **x << "\n";
|
||||||
|
|
||||||
OS << " Pairwise dependence results:\n";
|
OS << " Pairwise dependence results:\n";
|
||||||
for (SmallVector<Instruction*, 8>::const_iterator x = memrefs.begin(),
|
for (SmallVector<Instruction*, 8>::const_iterator x = memrefs.begin(),
|
||||||
end = memrefs.end(); x != end; ++x)
|
end = memrefs.end(); x != end; ++x)
|
||||||
for (SmallVector<Instruction*, 8>::const_iterator y = x + 1;
|
for (SmallVector<Instruction*, 8>::const_iterator y = x + 1;
|
||||||
y != end; ++y)
|
y != end; ++y)
|
||||||
if (LDA->isDependencePair(*x, *y))
|
if (LDA->isDependencePair(*x, *y))
|
||||||
OS << "\t" << (x - memrefs.begin()) << "," << (y - memrefs.begin())
|
OS << "\t" << (x - memrefs.begin()) << "," << (y - memrefs.begin())
|
||||||
<< ": " << (LDA->depends(*x, *y) ? "dependent" : "independent")
|
<< ": " << (LDA->depends(*x, *y) ? "dependent" : "independent")
|
||||||
|
Loading…
Reference in New Issue
Block a user