2003-10-13 03:32:08 +00:00
|
|
|
//===- LoopInfo.cpp - Natural Loop Calculator -----------------------------===//
|
2005-04-21 21:13:18 +00:00
|
|
|
//
|
2003-10-20 19:43:21 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 21:13:18 +00:00
|
|
|
//
|
2003-10-20 19:43:21 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-11-26 18:41:20 +00:00
|
|
|
//
|
|
|
|
// This file defines the LoopInfo class that is used to identify natural loops
|
|
|
|
// and determine the loop depth of various nodes of the CFG. Note that the
|
|
|
|
// loops identified may actually be several natural loops that share the same
|
|
|
|
// header node... not just a single natural loop.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2004-01-30 17:26:24 +00:00
|
|
|
#include "llvm/Analysis/LoopInfo.h"
|
2004-04-15 15:16:02 +00:00
|
|
|
#include "llvm/Constants.h"
|
|
|
|
#include "llvm/Instructions.h"
|
|
|
|
#include "llvm/Analysis/Dominators.h"
|
2002-07-27 01:12:17 +00:00
|
|
|
#include "llvm/Assembly/Writer.h"
|
2004-01-30 17:26:24 +00:00
|
|
|
#include "llvm/Support/CFG.h"
|
2006-11-28 22:46:12 +00:00
|
|
|
#include "llvm/Support/Streams.h"
|
2004-09-01 22:55:40 +00:00
|
|
|
#include "llvm/ADT/DepthFirstIterator.h"
|
2007-03-04 04:06:39 +00:00
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
2001-11-26 18:41:20 +00:00
|
|
|
#include <algorithm>
|
2004-04-12 20:26:17 +00:00
|
|
|
using namespace llvm;
|
2003-11-11 22:41:34 +00:00
|
|
|
|
2007-05-03 01:11:54 +00:00
|
|
|
char LoopInfo::ID = 0;
|
2006-08-27 22:30:17 +00:00
|
|
|
static RegisterPass<LoopInfo>
|
2009-05-01 21:58:05 +00:00
|
|
|
X("loops", "Natural Loop Information", true, true);
|
2002-01-31 00:42:27 +00:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2002-04-28 16:21:30 +00:00
|
|
|
// Loop implementation
|
2002-01-31 00:42:27 +00:00
|
|
|
//
|
2002-10-11 05:31:10 +00:00
|
|
|
|
2002-01-31 00:42:27 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-04-28 16:21:30 +00:00
|
|
|
// LoopInfo implementation
|
2002-01-31 00:42:27 +00:00
|
|
|
//
|
2002-06-25 16:13:24 +00:00
|
|
|
bool LoopInfo::runOnFunction(Function &) {
|
2002-04-09 05:43:19 +00:00
|
|
|
releaseMemory();
|
2009-06-27 21:22:48 +00:00
|
|
|
LI.Calculate(getAnalysis<DominatorTree>().getBase()); // Update
|
2002-01-31 00:42:27 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-04-28 16:21:30 +00:00
|
|
|
void LoopInfo::getAnalysisUsage(AnalysisUsage &AU) const {
|
2002-04-27 06:56:12 +00:00
|
|
|
AU.setPreservesAll();
|
2007-06-08 00:17:13 +00:00
|
|
|
AU.addRequired<DominatorTree>();
|
2002-01-31 00:42:27 +00:00
|
|
|
}
|