aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAndreas Bolka <a@bolka.at>2009-06-28 00:35:22 +0000
committerAndreas Bolka <a@bolka.at>2009-06-28 00:35:22 +0000
commit158c59013497ac416b9f0f05ae8f80135fab452e (patch)
tree5736833520ad1d7e06b9ba7a1fd95fe08b5b14c1 /lib
parentf17ab7f1e47fc16d61cca0ef423138bea314772d (diff)
downloadexternal_llvm-158c59013497ac416b9f0f05ae8f80135fab452e.zip
external_llvm-158c59013497ac416b9f0f05ae8f80135fab452e.tar.gz
external_llvm-158c59013497ac416b9f0f05ae8f80135fab452e.tar.bz2
Print pairwise dependence results, add testcases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74402 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/LoopDependenceAnalysis.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/Analysis/LoopDependenceAnalysis.cpp b/lib/Analysis/LoopDependenceAnalysis.cpp
index b23459e..4912bf2 100644
--- a/lib/Analysis/LoopDependenceAnalysis.cpp
+++ b/lib/Analysis/LoopDependenceAnalysis.cpp
@@ -40,6 +40,16 @@ static inline bool isMemRefInstr(const Value *I) {
return isa<LoadInst>(I) || isa<StoreInst>(I);
}
+static void getMemRefInstrs(
+ const Loop *L, SmallVectorImpl<Instruction*> &memrefs) {
+ for (Loop::block_iterator b = L->block_begin(), be = L->block_end();
+ b != be; ++b)
+ for (BasicBlock::iterator i = (*b)->begin(), ie = (*b)->end();
+ i != ie; ++i)
+ if (isMemRefInstr(i))
+ memrefs.push_back(i);
+}
+
//===----------------------------------------------------------------------===//
// Dependence Testing
//===----------------------------------------------------------------------===//
@@ -71,16 +81,30 @@ void LoopDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
}
static void PrintLoopInfo(
- raw_ostream &OS, const LoopDependenceAnalysis *LDA, const Loop *L) {
+ raw_ostream &OS, LoopDependenceAnalysis *LDA, const Loop *L) {
if (!L->empty()) return; // ignore non-innermost loops
OS << "Loop at depth " << L->getLoopDepth() << ", header block: ";
WriteAsOperand(OS, L->getHeader(), false);
OS << "\n";
+
+ SmallVector<Instruction*, 8> memrefs;
+ getMemRefInstrs(L, memrefs);
+ OS << " Load/store instructions: " << memrefs.size() << "\n";
+ OS << " Pairwise dependence results:\n";
+ for (SmallVector<Instruction*, 8>::const_iterator x = memrefs.begin(),
+ end = memrefs.end(); x != end; ++x)
+ for (SmallVector<Instruction*, 8>::const_iterator y = x + 1;
+ y != end; ++y)
+ if (LDA->isDependencePair(*x, *y))
+ OS << "\t" << (x - memrefs.begin()) << "," << (y - memrefs.begin())
+ << ": " << (LDA->depends(*x, *y) ? "dependent" : "independent")
+ << "\n";
}
void LoopDependenceAnalysis::print(raw_ostream &OS, const Module*) const {
- PrintLoopInfo(OS, this, this->L);
+ // TODO: doc why const_cast is safe
+ PrintLoopInfo(OS, const_cast<LoopDependenceAnalysis*>(this), this->L);
}
void LoopDependenceAnalysis::print(std::ostream &OS, const Module *M) const {