From 8976d3bc7e2d2facbb3e8b0ce0b70401baa89f40 Mon Sep 17 00:00:00 2001 From: Andreas Bolka Date: Sun, 28 Jun 2009 00:16:08 +0000 Subject: [PATCH] LDA analysis output scaffolding. llvm-svn: 74400 --- .../llvm/Analysis/LoopDependenceAnalysis.h | 9 ++++++++- llvm/lib/Analysis/LoopDependenceAnalysis.cpp | 20 ++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/Analysis/LoopDependenceAnalysis.h b/llvm/include/llvm/Analysis/LoopDependenceAnalysis.h index c69bc60bead2..0c3dadea75fc 100644 --- a/llvm/include/llvm/Analysis/LoopDependenceAnalysis.h +++ b/llvm/include/llvm/Analysis/LoopDependenceAnalysis.h @@ -21,11 +21,12 @@ #define LLVM_ANALYSIS_LOOP_DEPENDENCE_ANALYSIS_H #include "llvm/Analysis/LoopPass.h" +#include "llvm/Support/raw_ostream.h" +#include namespace llvm { class AnalysisUsage; - class LoopPass; class ScalarEvolution; class LoopDependenceAnalysis : public LoopPass { @@ -39,6 +40,12 @@ namespace llvm { bool runOnLoop(Loop*, LPPassManager&); virtual void getAnalysisUsage(AnalysisUsage&) const; + + void print(raw_ostream&, const Module* = 0) const; + virtual void print(std::ostream&, const Module* = 0) const; + void print(std::ostream *OS, const Module *M = 0) const { + if (OS) print(*OS, M); + } }; // class LoopDependenceAnalysis diff --git a/llvm/lib/Analysis/LoopDependenceAnalysis.cpp b/llvm/lib/Analysis/LoopDependenceAnalysis.cpp index 172a2be6bcf7..8f3e6baf5c57 100644 --- a/llvm/lib/Analysis/LoopDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/LoopDependenceAnalysis.cpp @@ -43,5 +43,23 @@ bool LoopDependenceAnalysis::runOnLoop(Loop *L, LPPassManager &) { void LoopDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); - AU.addRequired(); + AU.addRequiredTransitive(); +} + +static void PrintLoopInfo( + raw_ostream &OS, const 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"; +} + +void LoopDependenceAnalysis::print(raw_ostream &OS, const Module*) const { + PrintLoopInfo(OS, this, this->L); +} + +void LoopDependenceAnalysis::print(std::ostream &OS, const Module *M) const { + raw_os_ostream os(OS); + print(os, M); }