diff options
author | Chris Lattner <sabre@nondot.org> | 2002-01-31 00:42:06 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-01-31 00:42:06 +0000 |
commit | 0f0fc3253dd44b5b6d617812d37591fa26a28599 (patch) | |
tree | 8562fba19ca7f419b59ddbe0b95fddd5584a0fc9 /lib/Analysis | |
parent | 92a12d5c6bf7df4f023000719cdb5c9a31542716 (diff) | |
download | external_llvm-0f0fc3253dd44b5b6d617812d37591fa26a28599.zip external_llvm-0f0fc3253dd44b5b6d617812d37591fa26a28599.tar.gz external_llvm-0f0fc3253dd44b5b6d617812d37591fa26a28599.tar.bz2 |
Implement loop depth calculation in terms of dominators instead of intervals
No problems with irreducibility now
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1602 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/LoopDepth.cpp | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/lib/Analysis/LoopDepth.cpp b/lib/Analysis/LoopDepth.cpp index 994b7cd..e265837 100644 --- a/lib/Analysis/LoopDepth.cpp +++ b/lib/Analysis/LoopDepth.cpp @@ -6,39 +6,40 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/LoopDepth.h" -#include "llvm/Analysis/IntervalPartition.h" -#include "Support/STLExtras.h" +#include "llvm/Analysis/LoopInfo.h" +#include "llvm/Method.h" #include <algorithm> -inline void LoopDepthCalculator::AddBB(const BasicBlock *BB) { - ++LoopDepth[BB]; // Increment the loop depth count for the specified BB +AnalysisID cfg::LoopDepthCalculator::ID(AnalysisID::create<cfg::LoopDepthCalculator>()); + +bool cfg::LoopDepthCalculator::runOnMethod(Method *M) { + calculate(M, getAnalysis<LoopInfo>()); + return false; } -inline void LoopDepthCalculator::ProcessInterval(cfg::Interval *I) { - if (!I->isLoop()) return; // Ignore nonlooping intervals... +void cfg::LoopDepthCalculator::calculate(Method *M, LoopInfo &Loops) { + for (Method::iterator I = M->begin(), E = M->end(); I != E; ++I) + LoopDepth[*I] = Loops.getLoopDepth(*I); +} - for_each(I->Nodes.begin(), I->Nodes.end(), - bind_obj(this, &LoopDepthCalculator::AddBB)); +// getAnalysisUsageInfo - Provide loop depth, require loop info +// +void cfg::LoopDepthCalculator::getAnalysisUsageInfo(Pass::AnalysisSet &Requires, + Pass::AnalysisSet &Destroyed, + Pass::AnalysisSet &Provided) { + Provided.push_back(ID); + Requires.push_back(LoopInfo::ID); } -LoopDepthCalculator::LoopDepthCalculator(Method *M) { - cfg::IntervalPartition *IP = new cfg::IntervalPartition(M); - while (!IP->isDegeneratePartition()) { - for_each(IP->begin(), IP->end(), - bind_obj(this, &LoopDepthCalculator::ProcessInterval)); - - // Calculate the reduced version of this graph until we get to an - // irreducible graph or a degenerate graph... - // - cfg::IntervalPartition *NewIP = new cfg::IntervalPartition(*IP, true); - if (NewIP->size() == IP->size()) { - assert(0 && "IRREDUCIBLE GRAPH FOUND!!!\n"); - // TODO: fix irreducible graph - return; - } - delete IP; - IP = NewIP; - } - - delete IP; +#if 1 /// FIXME, REMOVE EVENTUALLY +#include "llvm/PassManager.h" + +cfg::LoopDepthCalculator::LoopDepthCalculator(Method *M) { + PassManagerT<Method> PassMgr; + LoopInfo *LI = new LoopInfo(LoopInfo::ID); + PassMgr.add(LI); + PassMgr.run(M); + calculate(M, *LI); } +#endif + |