From: Andreas Bolka Date: Tue, 28 Jul 2009 19:49:25 +0000 (+0000) Subject: Minor factoring, naming and formatting cleanups. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=34ce687144cbc7e2c55cac492ada44a63f0500bb;p=oota-llvm.git Minor factoring, naming and formatting cleanups. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77357 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/LoopDependenceAnalysis.cpp b/lib/Analysis/LoopDependenceAnalysis.cpp index 421e4e1ac18..97c85140126 100644 --- a/lib/Analysis/LoopDependenceAnalysis.cpp +++ b/lib/Analysis/LoopDependenceAnalysis.cpp @@ -50,9 +50,9 @@ static inline bool IsMemRefInstr(const Value *V) { static void GetMemRefInstrs(const Loop *L, SmallVectorImpl &Memrefs) { 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(); - i != ie; ++i) + i != ie; ++i) if (IsMemRefInstr(i)) Memrefs.push_back(i); } @@ -71,6 +71,15 @@ static Value *GetPointerOperand(Value *I) { 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 //===----------------------------------------------------------------------===// @@ -83,19 +92,19 @@ bool LoopDependenceAnalysis::isDependencePair(const Value *A, cast(B)->mayWriteToMemory()); } -bool LoopDependenceAnalysis::findOrInsertDependencePair(Value *X, - Value *Y, +bool LoopDependenceAnalysis::findOrInsertDependencePair(Value *A, + Value *B, DependencePair *&P) { void *insertPos = 0; FoldingSetNodeID id; - id.AddPointer(X); - id.AddPointer(Y); + id.AddPointer(A); + id.AddPointer(B); P = Pairs.FindNodeOrInsertPos(id, insertPos); if (P) return true; P = PairAllocator.Allocate(); - new (P) DependencePair(id, X, Y); + new (P) DependencePair(id, A, B); Pairs.InsertNode(P, insertPos); return false; } @@ -114,28 +123,24 @@ void LoopDependenceAnalysis::analysePair(DependencePair *P) const { return; } - Value *aptr = GetPointerOperand(P->A); - 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())); + Value *aPtr = GetPointerOperand(P->A); + Value *bPtr = GetPointerOperand(P->B); - // We can not analyse objects if we do not know about their aliasing. - if (alias == AliasAnalysis::MayAlias) { + switch (UnderlyingObjectsAlias(AA, aPtr, bPtr)) { + case AliasAnalysis::MayAlias: + // We can not analyse objects if we do not know about their aliasing. DEBUG(errs() << "---> [?] may alias\n"); return; - } - // If the objects noalias, they are distinct, accesses are independent. - if (alias == AliasAnalysis::NoAlias) { + case AliasAnalysis::NoAlias: + // If the objects noalias, they are distinct, accesses are independent. DEBUG(errs() << "---> [I] no alias\n"); P->Result = Independent; 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"); return; @@ -187,14 +192,14 @@ static void PrintLoopInfo(raw_ostream &OS, OS << " Load/store instructions: " << memrefs.size() << "\n"; for (SmallVector::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 << " Pairwise dependence results:\n"; for (SmallVector::const_iterator x = memrefs.begin(), - end = memrefs.end(); x != end; ++x) + end = memrefs.end(); x != end; ++x) for (SmallVector::const_iterator y = x + 1; - y != end; ++y) + y != end; ++y) if (LDA->isDependencePair(*x, *y)) OS << "\t" << (x - memrefs.begin()) << "," << (y - memrefs.begin()) << ": " << (LDA->depends(*x, *y) ? "dependent" : "independent")