2010-07-22 15:46:31 +08:00
|
|
|
//===- RegionInfo.cpp - SESE region detection analysis --------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Detects single entry single exit regions in the control flow graph.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Analysis/RegionInfo.h"
|
|
|
|
#include "llvm/ADT/PostOrderIterator.h"
|
|
|
|
#include "llvm/ADT/Statistic.h"
|
2010-07-27 12:17:13 +08:00
|
|
|
#include "llvm/Analysis/LoopInfo.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/Analysis/RegionIterator.h"
|
|
|
|
#include "llvm/Support/CommandLine.h"
|
2010-07-22 15:46:31 +08:00
|
|
|
#include "llvm/Support/Debug.h"
|
2014-01-07 19:48:04 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2010-07-22 15:46:31 +08:00
|
|
|
#include <algorithm>
|
2014-04-16 02:32:43 +08:00
|
|
|
#include <iterator>
|
2013-08-22 05:14:19 +08:00
|
|
|
#include <set>
|
2010-07-22 15:46:31 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2014-04-22 10:48:03 +08:00
|
|
|
#define DEBUG_TYPE "region"
|
|
|
|
|
2010-07-22 15:46:31 +08:00
|
|
|
// Always verify if expensive checking is enabled.
|
|
|
|
#ifdef XDEBUG
|
2010-08-03 02:50:06 +08:00
|
|
|
static bool VerifyRegionInfo = true;
|
2010-07-22 15:46:31 +08:00
|
|
|
#else
|
2010-08-03 02:50:06 +08:00
|
|
|
static bool VerifyRegionInfo = false;
|
2010-07-22 15:46:31 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static cl::opt<bool,true>
|
|
|
|
VerifyRegionInfoX("verify-region-info", cl::location(VerifyRegionInfo),
|
|
|
|
cl::desc("Verify region info (time consuming)"));
|
|
|
|
|
|
|
|
STATISTIC(numRegions, "The # of regions");
|
|
|
|
STATISTIC(numSimpleRegions, "The # of simple regions");
|
|
|
|
|
2011-04-04 15:19:18 +08:00
|
|
|
static cl::opt<enum Region::PrintStyle> printStyle("print-region-style",
|
|
|
|
cl::Hidden,
|
2010-07-22 15:46:31 +08:00
|
|
|
cl::desc("style of printing regions"),
|
|
|
|
cl::values(
|
2011-04-04 15:19:18 +08:00
|
|
|
clEnumValN(Region::PrintNone, "none", "print no details"),
|
|
|
|
clEnumValN(Region::PrintBB, "bb",
|
2012-08-27 21:49:24 +08:00
|
|
|
"print regions in detail with block_iterator"),
|
2011-04-04 15:19:18 +08:00
|
|
|
clEnumValN(Region::PrintRN, "rn",
|
|
|
|
"print regions in detail with element_iterator"),
|
2010-07-22 15:46:31 +08:00
|
|
|
clEnumValEnd));
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// Region Implementation
|
|
|
|
Region::Region(BasicBlock *Entry, BasicBlock *Exit, RegionInfo* RInfo,
|
|
|
|
DominatorTree *dt, Region *Parent)
|
|
|
|
: RegionNode(Parent, Entry, 1), RI(RInfo), DT(dt), exit(Exit) {}
|
|
|
|
|
|
|
|
Region::~Region() {
|
2010-07-29 04:28:50 +08:00
|
|
|
// Free the cached nodes.
|
|
|
|
for (BBNodeMapT::iterator it = BBNodeMap.begin(),
|
|
|
|
ie = BBNodeMap.end(); it != ie; ++it)
|
|
|
|
delete it->second;
|
|
|
|
|
2010-07-22 15:46:31 +08:00
|
|
|
// Only clean the cache for this Region. Caches of child Regions will be
|
|
|
|
// cleaned when the child Regions are deleted.
|
|
|
|
BBNodeMap.clear();
|
|
|
|
}
|
|
|
|
|
2010-10-13 13:54:10 +08:00
|
|
|
void Region::replaceEntry(BasicBlock *BB) {
|
|
|
|
entry.setPointer(BB);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Region::replaceExit(BasicBlock *BB) {
|
|
|
|
assert(exit && "No exit to replace!");
|
|
|
|
exit = BB;
|
|
|
|
}
|
|
|
|
|
2013-04-10 14:54:49 +08:00
|
|
|
void Region::replaceEntryRecursive(BasicBlock *NewEntry) {
|
|
|
|
std::vector<Region *> RegionQueue;
|
|
|
|
BasicBlock *OldEntry = getEntry();
|
|
|
|
|
|
|
|
RegionQueue.push_back(this);
|
|
|
|
while (!RegionQueue.empty()) {
|
|
|
|
Region *R = RegionQueue.back();
|
|
|
|
RegionQueue.pop_back();
|
|
|
|
|
|
|
|
R->replaceEntry(NewEntry);
|
|
|
|
for (Region::const_iterator RI = R->begin(), RE = R->end(); RI != RE; ++RI)
|
|
|
|
if ((*RI)->getEntry() == OldEntry)
|
2014-04-16 02:32:43 +08:00
|
|
|
RegionQueue.push_back(RI->get());
|
2013-04-10 14:54:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Region::replaceExitRecursive(BasicBlock *NewExit) {
|
|
|
|
std::vector<Region *> RegionQueue;
|
|
|
|
BasicBlock *OldExit = getExit();
|
|
|
|
|
|
|
|
RegionQueue.push_back(this);
|
|
|
|
while (!RegionQueue.empty()) {
|
|
|
|
Region *R = RegionQueue.back();
|
|
|
|
RegionQueue.pop_back();
|
|
|
|
|
|
|
|
R->replaceExit(NewExit);
|
|
|
|
for (Region::const_iterator RI = R->begin(), RE = R->end(); RI != RE; ++RI)
|
|
|
|
if ((*RI)->getExit() == OldExit)
|
2014-04-16 02:32:43 +08:00
|
|
|
RegionQueue.push_back(RI->get());
|
2013-04-10 14:54:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-22 15:46:31 +08:00
|
|
|
bool Region::contains(const BasicBlock *B) const {
|
|
|
|
BasicBlock *BB = const_cast<BasicBlock*>(B);
|
|
|
|
|
2013-05-03 23:48:34 +08:00
|
|
|
if (!DT->getNode(BB))
|
|
|
|
return false;
|
2010-07-22 15:46:31 +08:00
|
|
|
|
|
|
|
BasicBlock *entry = getEntry(), *exit = getExit();
|
|
|
|
|
|
|
|
// Toplevel region.
|
|
|
|
if (!exit)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return (DT->dominates(entry, BB)
|
|
|
|
&& !(DT->dominates(exit, BB) && DT->dominates(entry, exit)));
|
|
|
|
}
|
|
|
|
|
2010-07-27 12:17:13 +08:00
|
|
|
bool Region::contains(const Loop *L) const {
|
|
|
|
// BBs that are not part of any loop are element of the Loop
|
|
|
|
// described by the NULL pointer. This loop is not part of any region,
|
|
|
|
// except if the region describes the whole function.
|
2014-04-15 12:59:12 +08:00
|
|
|
if (!L)
|
|
|
|
return getExit() == nullptr;
|
2010-07-27 12:17:13 +08:00
|
|
|
|
|
|
|
if (!contains(L->getHeader()))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
SmallVector<BasicBlock *, 8> ExitingBlocks;
|
|
|
|
L->getExitingBlocks(ExitingBlocks);
|
|
|
|
|
|
|
|
for (SmallVectorImpl<BasicBlock*>::iterator BI = ExitingBlocks.begin(),
|
|
|
|
BE = ExitingBlocks.end(); BI != BE; ++BI)
|
|
|
|
if (!contains(*BI))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Loop *Region::outermostLoopInRegion(Loop *L) const {
|
|
|
|
if (!contains(L))
|
2014-04-15 12:59:12 +08:00
|
|
|
return nullptr;
|
2010-07-27 12:17:13 +08:00
|
|
|
|
|
|
|
while (L && contains(L->getParentLoop())) {
|
|
|
|
L = L->getParentLoop();
|
|
|
|
}
|
|
|
|
|
|
|
|
return L;
|
|
|
|
}
|
|
|
|
|
|
|
|
Loop *Region::outermostLoopInRegion(LoopInfo *LI, BasicBlock* BB) const {
|
|
|
|
assert(LI && BB && "LI and BB cannot be null!");
|
|
|
|
Loop *L = LI->getLoopFor(BB);
|
|
|
|
return outermostLoopInRegion(L);
|
|
|
|
}
|
|
|
|
|
2011-01-14 07:18:04 +08:00
|
|
|
BasicBlock *Region::getEnteringBlock() const {
|
|
|
|
BasicBlock *entry = getEntry();
|
|
|
|
BasicBlock *Pred;
|
2014-04-15 12:59:12 +08:00
|
|
|
BasicBlock *enteringBlock = nullptr;
|
2010-07-22 15:46:31 +08:00
|
|
|
|
|
|
|
for (pred_iterator PI = pred_begin(entry), PE = pred_end(entry); PI != PE;
|
2010-08-10 17:54:35 +08:00
|
|
|
++PI) {
|
2011-01-14 07:18:04 +08:00
|
|
|
Pred = *PI;
|
2010-08-10 17:54:35 +08:00
|
|
|
if (DT->getNode(Pred) && !contains(Pred)) {
|
2011-01-14 07:18:04 +08:00
|
|
|
if (enteringBlock)
|
2014-04-15 12:59:12 +08:00
|
|
|
return nullptr;
|
2011-01-14 07:18:04 +08:00
|
|
|
|
|
|
|
enteringBlock = Pred;
|
2010-07-22 15:46:31 +08:00
|
|
|
}
|
2010-08-10 17:54:35 +08:00
|
|
|
}
|
2010-07-22 15:46:31 +08:00
|
|
|
|
2011-01-14 07:18:04 +08:00
|
|
|
return enteringBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
BasicBlock *Region::getExitingBlock() const {
|
|
|
|
BasicBlock *exit = getExit();
|
|
|
|
BasicBlock *Pred;
|
2014-04-15 12:59:12 +08:00
|
|
|
BasicBlock *exitingBlock = nullptr;
|
2011-01-14 07:18:04 +08:00
|
|
|
|
|
|
|
if (!exit)
|
2014-04-15 12:59:12 +08:00
|
|
|
return nullptr;
|
2010-07-22 15:46:31 +08:00
|
|
|
|
|
|
|
for (pred_iterator PI = pred_begin(exit), PE = pred_end(exit); PI != PE;
|
2011-01-14 07:18:04 +08:00
|
|
|
++PI) {
|
|
|
|
Pred = *PI;
|
|
|
|
if (contains(Pred)) {
|
|
|
|
if (exitingBlock)
|
2014-04-15 12:59:12 +08:00
|
|
|
return nullptr;
|
2011-01-14 07:18:04 +08:00
|
|
|
|
|
|
|
exitingBlock = Pred;
|
2010-07-22 15:46:31 +08:00
|
|
|
}
|
2011-01-14 07:18:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return exitingBlock;
|
|
|
|
}
|
2010-07-22 15:46:31 +08:00
|
|
|
|
2011-01-14 07:18:04 +08:00
|
|
|
bool Region::isSimple() const {
|
|
|
|
return !isTopLevelRegion() && getEnteringBlock() && getExitingBlock();
|
2010-07-22 15:46:31 +08:00
|
|
|
}
|
|
|
|
|
2010-07-27 12:17:13 +08:00
|
|
|
std::string Region::getNameStr() const {
|
|
|
|
std::string exitName;
|
|
|
|
std::string entryName;
|
|
|
|
|
|
|
|
if (getEntry()->getName().empty()) {
|
|
|
|
raw_string_ostream OS(entryName);
|
|
|
|
|
2014-01-09 10:29:41 +08:00
|
|
|
getEntry()->printAsOperand(OS, false);
|
2010-07-27 12:17:13 +08:00
|
|
|
} else
|
2011-11-16 02:30:06 +08:00
|
|
|
entryName = getEntry()->getName();
|
2010-07-27 12:17:13 +08:00
|
|
|
|
|
|
|
if (getExit()) {
|
|
|
|
if (getExit()->getName().empty()) {
|
|
|
|
raw_string_ostream OS(exitName);
|
|
|
|
|
2014-01-09 10:29:41 +08:00
|
|
|
getExit()->printAsOperand(OS, false);
|
2010-07-27 12:17:13 +08:00
|
|
|
} else
|
2011-11-16 02:30:06 +08:00
|
|
|
exitName = getExit()->getName();
|
2010-07-27 12:17:13 +08:00
|
|
|
} else
|
|
|
|
exitName = "<Function Return>";
|
|
|
|
|
|
|
|
return entryName + " => " + exitName;
|
|
|
|
}
|
|
|
|
|
2010-07-22 15:46:31 +08:00
|
|
|
void Region::verifyBBInRegion(BasicBlock *BB) const {
|
|
|
|
if (!contains(BB))
|
|
|
|
llvm_unreachable("Broken region found!");
|
|
|
|
|
|
|
|
BasicBlock *entry = getEntry(), *exit = getExit();
|
|
|
|
|
|
|
|
for (succ_iterator SI = succ_begin(BB), SE = succ_end(BB); SI != SE; ++SI)
|
|
|
|
if (!contains(*SI) && exit != *SI)
|
|
|
|
llvm_unreachable("Broken region found!");
|
|
|
|
|
|
|
|
if (entry != BB)
|
|
|
|
for (pred_iterator SI = pred_begin(BB), SE = pred_end(BB); SI != SE; ++SI)
|
|
|
|
if (!contains(*SI))
|
|
|
|
llvm_unreachable("Broken region found!");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Region::verifyWalk(BasicBlock *BB, std::set<BasicBlock*> *visited) const {
|
|
|
|
BasicBlock *exit = getExit();
|
|
|
|
|
|
|
|
visited->insert(BB);
|
|
|
|
|
|
|
|
verifyBBInRegion(BB);
|
|
|
|
|
|
|
|
for (succ_iterator SI = succ_begin(BB), SE = succ_end(BB); SI != SE; ++SI)
|
|
|
|
if (*SI != exit && visited->find(*SI) == visited->end())
|
|
|
|
verifyWalk(*SI, visited);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Region::verifyRegion() const {
|
|
|
|
// Only do verification when user wants to, otherwise this expensive
|
|
|
|
// check will be invoked by PassManager.
|
|
|
|
if (!VerifyRegionInfo) return;
|
|
|
|
|
|
|
|
std::set<BasicBlock*> visited;
|
|
|
|
verifyWalk(getEntry(), &visited);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Region::verifyRegionNest() const {
|
|
|
|
for (Region::const_iterator RI = begin(), RE = end(); RI != RE; ++RI)
|
|
|
|
(*RI)->verifyRegionNest();
|
|
|
|
|
|
|
|
verifyRegion();
|
|
|
|
}
|
|
|
|
|
|
|
|
Region::element_iterator Region::element_begin() {
|
|
|
|
return GraphTraits<Region*>::nodes_begin(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Region::element_iterator Region::element_end() {
|
|
|
|
return GraphTraits<Region*>::nodes_end(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Region::const_element_iterator Region::element_begin() const {
|
|
|
|
return GraphTraits<const Region*>::nodes_begin(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Region::const_element_iterator Region::element_end() const {
|
|
|
|
return GraphTraits<const Region*>::nodes_end(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Region* Region::getSubRegionNode(BasicBlock *BB) const {
|
|
|
|
Region *R = RI->getRegionFor(BB);
|
|
|
|
|
|
|
|
if (!R || R == this)
|
2014-04-15 12:59:12 +08:00
|
|
|
return nullptr;
|
2010-07-22 15:46:31 +08:00
|
|
|
|
|
|
|
// If we pass the BB out of this region, that means our code is broken.
|
|
|
|
assert(contains(R) && "BB not in current region!");
|
|
|
|
|
|
|
|
while (contains(R->getParent()) && R->getParent() != this)
|
|
|
|
R = R->getParent();
|
|
|
|
|
|
|
|
if (R->getEntry() != BB)
|
2014-04-15 12:59:12 +08:00
|
|
|
return nullptr;
|
2010-07-22 15:46:31 +08:00
|
|
|
|
|
|
|
return R;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegionNode* Region::getBBNode(BasicBlock *BB) const {
|
|
|
|
assert(contains(BB) && "Can get BB node out of this region!");
|
|
|
|
|
|
|
|
BBNodeMapT::const_iterator at = BBNodeMap.find(BB);
|
|
|
|
|
|
|
|
if (at != BBNodeMap.end())
|
|
|
|
return at->second;
|
|
|
|
|
|
|
|
RegionNode *NewNode = new RegionNode(const_cast<Region*>(this), BB);
|
|
|
|
BBNodeMap.insert(std::make_pair(BB, NewNode));
|
|
|
|
return NewNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegionNode* Region::getNode(BasicBlock *BB) const {
|
|
|
|
assert(contains(BB) && "Can get BB node out of this region!");
|
|
|
|
if (Region* Child = getSubRegionNode(BB))
|
|
|
|
return Child->getNode();
|
|
|
|
|
|
|
|
return getBBNode(BB);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Region::transferChildrenTo(Region *To) {
|
|
|
|
for (iterator I = begin(), E = end(); I != E; ++I) {
|
|
|
|
(*I)->parent = To;
|
2014-04-16 02:32:43 +08:00
|
|
|
To->children.push_back(std::move(*I));
|
2010-07-22 15:46:31 +08:00
|
|
|
}
|
|
|
|
children.clear();
|
|
|
|
}
|
|
|
|
|
2010-10-13 13:54:09 +08:00
|
|
|
void Region::addSubRegion(Region *SubRegion, bool moveChildren) {
|
2014-04-15 12:59:12 +08:00
|
|
|
assert(!SubRegion->parent && "SubRegion already has a parent!");
|
2014-04-16 02:32:43 +08:00
|
|
|
assert(std::find_if(begin(), end(), [&](const std::unique_ptr<Region> &R) {
|
|
|
|
return R.get() == SubRegion;
|
|
|
|
}) == children.end() &&
|
|
|
|
"Subregion already exists!");
|
2010-10-13 13:54:09 +08:00
|
|
|
|
2010-07-22 15:46:31 +08:00
|
|
|
SubRegion->parent = this;
|
2014-04-16 02:32:43 +08:00
|
|
|
children.push_back(std::unique_ptr<Region>(SubRegion));
|
2010-10-13 13:54:09 +08:00
|
|
|
|
|
|
|
if (!moveChildren)
|
|
|
|
return;
|
|
|
|
|
|
|
|
assert(SubRegion->children.size() == 0
|
|
|
|
&& "SubRegions that contain children are not supported");
|
|
|
|
|
|
|
|
for (element_iterator I = element_begin(), E = element_end(); I != E; ++I)
|
|
|
|
if (!(*I)->isSubRegion()) {
|
|
|
|
BasicBlock *BB = (*I)->getNodeAs<BasicBlock>();
|
|
|
|
|
|
|
|
if (SubRegion->contains(BB))
|
|
|
|
RI->setRegionFor(BB, SubRegion);
|
|
|
|
}
|
|
|
|
|
2014-04-16 02:32:43 +08:00
|
|
|
std::vector<std::unique_ptr<Region>> Keep;
|
2010-10-13 13:54:09 +08:00
|
|
|
for (iterator I = begin(), E = end(); I != E; ++I)
|
2014-04-16 02:32:43 +08:00
|
|
|
if (SubRegion->contains(I->get()) && I->get() != SubRegion) {
|
2010-10-13 13:54:09 +08:00
|
|
|
(*I)->parent = SubRegion;
|
2014-04-16 06:09:36 +08:00
|
|
|
SubRegion->children.push_back(std::move(*I));
|
2010-10-13 13:54:09 +08:00
|
|
|
} else
|
2014-04-16 02:32:43 +08:00
|
|
|
Keep.push_back(std::move(*I));
|
2010-10-13 13:54:09 +08:00
|
|
|
|
|
|
|
children.clear();
|
2014-04-16 02:32:43 +08:00
|
|
|
children.insert(children.begin(),
|
|
|
|
std::move_iterator<RegionSet::iterator>(Keep.begin()),
|
|
|
|
std::move_iterator<RegionSet::iterator>(Keep.end()));
|
2010-07-22 15:46:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Region *Region::removeSubRegion(Region *Child) {
|
|
|
|
assert(Child->parent == this && "Child is not a child of this region!");
|
2014-04-15 12:59:12 +08:00
|
|
|
Child->parent = nullptr;
|
2014-04-16 02:32:43 +08:00
|
|
|
RegionSet::iterator I = std::find_if(
|
|
|
|
children.begin(), children.end(),
|
|
|
|
[&](const std::unique_ptr<Region> &R) { return R.get() == Child; });
|
2010-07-22 15:46:31 +08:00
|
|
|
assert(I != children.end() && "Region does not exit. Unable to remove.");
|
|
|
|
children.erase(children.begin()+(I-begin()));
|
|
|
|
return Child;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned Region::getDepth() const {
|
|
|
|
unsigned Depth = 0;
|
|
|
|
|
2014-04-15 12:59:12 +08:00
|
|
|
for (Region *R = parent; R != nullptr; R = R->parent)
|
2010-07-22 15:46:31 +08:00
|
|
|
++Depth;
|
|
|
|
|
|
|
|
return Depth;
|
|
|
|
}
|
|
|
|
|
2010-10-13 13:54:11 +08:00
|
|
|
Region *Region::getExpandedRegion() const {
|
|
|
|
unsigned NumSuccessors = exit->getTerminator()->getNumSuccessors();
|
|
|
|
|
|
|
|
if (NumSuccessors == 0)
|
2014-04-15 12:59:12 +08:00
|
|
|
return nullptr;
|
2010-10-13 13:54:11 +08:00
|
|
|
|
|
|
|
for (pred_iterator PI = pred_begin(getExit()), PE = pred_end(getExit());
|
|
|
|
PI != PE; ++PI)
|
|
|
|
if (!DT->dominates(getEntry(), *PI))
|
2014-04-15 12:59:12 +08:00
|
|
|
return nullptr;
|
2010-10-13 13:54:11 +08:00
|
|
|
|
|
|
|
Region *R = RI->getRegionFor(exit);
|
|
|
|
|
|
|
|
if (R->getEntry() != exit) {
|
|
|
|
if (exit->getTerminator()->getNumSuccessors() == 1)
|
|
|
|
return new Region(getEntry(), *succ_begin(exit), RI, DT);
|
|
|
|
else
|
2014-04-15 12:59:12 +08:00
|
|
|
return nullptr;
|
2010-10-13 13:54:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
while (R->getParent() && R->getParent()->getEntry() == exit)
|
|
|
|
R = R->getParent();
|
|
|
|
|
|
|
|
if (!DT->dominates(getEntry(), R->getExit()))
|
|
|
|
for (pred_iterator PI = pred_begin(getExit()), PE = pred_end(getExit());
|
|
|
|
PI != PE; ++PI)
|
|
|
|
if (!DT->dominates(R->getExit(), *PI))
|
2014-04-15 12:59:12 +08:00
|
|
|
return nullptr;
|
2010-10-13 13:54:11 +08:00
|
|
|
|
|
|
|
return new Region(getEntry(), R->getExit(), RI, DT);
|
|
|
|
}
|
|
|
|
|
2011-04-04 15:19:18 +08:00
|
|
|
void Region::print(raw_ostream &OS, bool print_tree, unsigned level,
|
|
|
|
enum PrintStyle Style) const {
|
2010-07-22 15:46:31 +08:00
|
|
|
if (print_tree)
|
|
|
|
OS.indent(level*2) << "[" << level << "] " << getNameStr();
|
|
|
|
else
|
|
|
|
OS.indent(level*2) << getNameStr();
|
|
|
|
|
|
|
|
OS << "\n";
|
|
|
|
|
|
|
|
|
2011-04-04 15:19:18 +08:00
|
|
|
if (Style != PrintNone) {
|
2010-07-22 15:46:31 +08:00
|
|
|
OS.indent(level*2) << "{\n";
|
|
|
|
OS.indent(level*2 + 2);
|
|
|
|
|
2011-04-04 15:19:18 +08:00
|
|
|
if (Style == PrintBB) {
|
2014-03-03 21:00:39 +08:00
|
|
|
for (const auto &BB : blocks())
|
|
|
|
OS << BB->getName() << ", "; // TODO: remove the last ","
|
2011-04-04 15:19:18 +08:00
|
|
|
} else if (Style == PrintRN) {
|
2010-07-22 15:46:31 +08:00
|
|
|
for (const_element_iterator I = element_begin(), E = element_end(); I!=E; ++I)
|
|
|
|
OS << **I << ", "; // TODO: remove the last ",
|
|
|
|
}
|
|
|
|
|
|
|
|
OS << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (print_tree)
|
|
|
|
for (const_iterator RI = begin(), RE = end(); RI != RE; ++RI)
|
2011-04-04 15:19:18 +08:00
|
|
|
(*RI)->print(OS, print_tree, level+1, Style);
|
2010-07-22 15:46:31 +08:00
|
|
|
|
2011-04-04 15:19:18 +08:00
|
|
|
if (Style != PrintNone)
|
2010-07-22 15:46:31 +08:00
|
|
|
OS.indent(level*2) << "} \n";
|
|
|
|
}
|
|
|
|
|
2012-09-12 13:06:18 +08:00
|
|
|
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
|
2010-07-22 15:46:31 +08:00
|
|
|
void Region::dump() const {
|
2011-04-04 15:19:18 +08:00
|
|
|
print(dbgs(), true, getDepth(), printStyle.getValue());
|
2010-07-22 15:46:31 +08:00
|
|
|
}
|
2012-09-07 03:55:56 +08:00
|
|
|
#endif
|
2010-07-22 15:46:31 +08:00
|
|
|
|
|
|
|
void Region::clearNodeCache() {
|
2010-10-13 08:07:59 +08:00
|
|
|
// Free the cached nodes.
|
|
|
|
for (BBNodeMapT::iterator I = BBNodeMap.begin(),
|
2010-10-13 16:00:53 +08:00
|
|
|
IE = BBNodeMap.end(); I != IE; ++I)
|
2010-10-13 08:07:59 +08:00
|
|
|
delete I->second;
|
|
|
|
|
2010-07-22 15:46:31 +08:00
|
|
|
BBNodeMap.clear();
|
|
|
|
for (Region::iterator RI = begin(), RE = end(); RI != RE; ++RI)
|
|
|
|
(*RI)->clearNodeCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// RegionInfo implementation
|
|
|
|
//
|
|
|
|
|
|
|
|
bool RegionInfo::isCommonDomFrontier(BasicBlock *BB, BasicBlock *entry,
|
|
|
|
BasicBlock *exit) const {
|
2010-07-22 19:07:46 +08:00
|
|
|
for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE; ++PI) {
|
|
|
|
BasicBlock *P = *PI;
|
|
|
|
if (DT->dominates(entry, P) && !DT->dominates(exit, P))
|
2010-07-22 15:46:31 +08:00
|
|
|
return false;
|
2010-07-22 19:07:46 +08:00
|
|
|
}
|
2010-07-22 15:46:31 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RegionInfo::isRegion(BasicBlock *entry, BasicBlock *exit) const {
|
|
|
|
assert(entry && exit && "entry and exit must not be null!");
|
|
|
|
typedef DominanceFrontier::DomSetType DST;
|
|
|
|
|
2010-07-22 19:12:32 +08:00
|
|
|
DST *entrySuccs = &DF->find(entry)->second;
|
2010-07-22 15:46:31 +08:00
|
|
|
|
|
|
|
// Exit is the header of a loop that contains the entry. In this case,
|
|
|
|
// the dominance frontier must only contain the exit.
|
|
|
|
if (!DT->dominates(entry, exit)) {
|
|
|
|
for (DST::iterator SI = entrySuccs->begin(), SE = entrySuccs->end();
|
|
|
|
SI != SE; ++SI)
|
|
|
|
if (*SI != exit && *SI != entry)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-22 19:12:32 +08:00
|
|
|
DST *exitSuccs = &DF->find(exit)->second;
|
2010-07-22 15:46:31 +08:00
|
|
|
|
|
|
|
// Do not allow edges leaving the region.
|
|
|
|
for (DST::iterator SI = entrySuccs->begin(), SE = entrySuccs->end();
|
|
|
|
SI != SE; ++SI) {
|
|
|
|
if (*SI == exit || *SI == entry)
|
|
|
|
continue;
|
|
|
|
if (exitSuccs->find(*SI) == exitSuccs->end())
|
|
|
|
return false;
|
|
|
|
if (!isCommonDomFrontier(*SI, entry, exit))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do not allow edges pointing into the region.
|
|
|
|
for (DST::iterator SI = exitSuccs->begin(), SE = exitSuccs->end();
|
|
|
|
SI != SE; ++SI)
|
2010-07-27 01:34:05 +08:00
|
|
|
if (DT->properlyDominates(entry, *SI) && *SI != exit)
|
2010-07-22 15:46:31 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RegionInfo::insertShortCut(BasicBlock *entry, BasicBlock *exit,
|
|
|
|
BBtoBBMap *ShortCut) const {
|
|
|
|
assert(entry && exit && "entry and exit must not be null!");
|
|
|
|
|
|
|
|
BBtoBBMap::iterator e = ShortCut->find(exit);
|
|
|
|
|
|
|
|
if (e == ShortCut->end())
|
|
|
|
// No further region at exit available.
|
|
|
|
(*ShortCut)[entry] = exit;
|
|
|
|
else {
|
|
|
|
// We found a region e that starts at exit. Therefore (entry, e->second)
|
|
|
|
// is also a region, that is larger than (entry, exit). Insert the
|
|
|
|
// larger one.
|
|
|
|
BasicBlock *BB = e->second;
|
|
|
|
(*ShortCut)[entry] = BB;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DomTreeNode* RegionInfo::getNextPostDom(DomTreeNode* N,
|
|
|
|
BBtoBBMap *ShortCut) const {
|
|
|
|
BBtoBBMap::iterator e = ShortCut->find(N->getBlock());
|
|
|
|
|
|
|
|
if (e == ShortCut->end())
|
|
|
|
return N->getIDom();
|
|
|
|
|
|
|
|
return PDT->getNode(e->second)->getIDom();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RegionInfo::isTrivialRegion(BasicBlock *entry, BasicBlock *exit) const {
|
|
|
|
assert(entry && exit && "entry and exit must not be null!");
|
|
|
|
|
|
|
|
unsigned num_successors = succ_end(entry) - succ_begin(entry);
|
|
|
|
|
|
|
|
if (num_successors <= 1 && exit == *(succ_begin(entry)))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RegionInfo::updateStatistics(Region *R) {
|
|
|
|
++numRegions;
|
|
|
|
|
|
|
|
// TODO: Slow. Should only be enabled if -stats is used.
|
|
|
|
if (R->isSimple()) ++numSimpleRegions;
|
|
|
|
}
|
|
|
|
|
|
|
|
Region *RegionInfo::createRegion(BasicBlock *entry, BasicBlock *exit) {
|
|
|
|
assert(entry && exit && "entry and exit must not be null!");
|
|
|
|
|
|
|
|
if (isTrivialRegion(entry, exit))
|
2014-04-15 12:59:12 +08:00
|
|
|
return nullptr;
|
2010-07-22 15:46:31 +08:00
|
|
|
|
|
|
|
Region *region = new Region(entry, exit, this, DT);
|
|
|
|
BBtoRegion.insert(std::make_pair(entry, region));
|
|
|
|
|
|
|
|
#ifdef XDEBUG
|
|
|
|
region->verifyRegion();
|
|
|
|
#else
|
|
|
|
DEBUG(region->verifyRegion());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
updateStatistics(region);
|
|
|
|
return region;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RegionInfo::findRegionsWithEntry(BasicBlock *entry, BBtoBBMap *ShortCut) {
|
|
|
|
assert(entry);
|
|
|
|
|
|
|
|
DomTreeNode *N = PDT->getNode(entry);
|
|
|
|
|
|
|
|
if (!N)
|
|
|
|
return;
|
|
|
|
|
2014-04-15 12:59:12 +08:00
|
|
|
Region *lastRegion= nullptr;
|
2010-07-22 15:46:31 +08:00
|
|
|
BasicBlock *lastExit = entry;
|
|
|
|
|
|
|
|
// As only a BasicBlock that postdominates entry can finish a region, walk the
|
|
|
|
// post dominance tree upwards.
|
|
|
|
while ((N = getNextPostDom(N, ShortCut))) {
|
|
|
|
BasicBlock *exit = N->getBlock();
|
|
|
|
|
|
|
|
if (!exit)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (isRegion(entry, exit)) {
|
|
|
|
Region *newRegion = createRegion(entry, exit);
|
|
|
|
|
|
|
|
if (lastRegion)
|
|
|
|
newRegion->addSubRegion(lastRegion);
|
|
|
|
|
|
|
|
lastRegion = newRegion;
|
|
|
|
lastExit = exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This can never be a region, so stop the search.
|
|
|
|
if (!DT->dominates(entry, exit))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tried to create regions from entry to lastExit. Next time take a
|
|
|
|
// shortcut from entry to lastExit.
|
|
|
|
if (lastExit != entry)
|
|
|
|
insertShortCut(entry, lastExit, ShortCut);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RegionInfo::scanForRegions(Function &F, BBtoBBMap *ShortCut) {
|
|
|
|
BasicBlock *entry = &(F.getEntryBlock());
|
|
|
|
DomTreeNode *N = DT->getNode(entry);
|
|
|
|
|
|
|
|
// Iterate over the dominance tree in post order to start with the small
|
|
|
|
// regions from the bottom of the dominance tree. If the small regions are
|
|
|
|
// detected first, detection of bigger regions is faster, as we can jump
|
|
|
|
// over the small regions.
|
|
|
|
for (po_iterator<DomTreeNode*> FI = po_begin(N), FE = po_end(N); FI != FE;
|
|
|
|
++FI) {
|
2010-07-22 21:49:27 +08:00
|
|
|
findRegionsWithEntry(FI->getBlock(), ShortCut);
|
2010-07-22 15:46:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Region *RegionInfo::getTopMostParent(Region *region) {
|
|
|
|
while (region->parent)
|
|
|
|
region = region->getParent();
|
|
|
|
|
|
|
|
return region;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RegionInfo::buildRegionsTree(DomTreeNode *N, Region *region) {
|
|
|
|
BasicBlock *BB = N->getBlock();
|
|
|
|
|
|
|
|
// Passed region exit
|
|
|
|
while (BB == region->getExit())
|
|
|
|
region = region->getParent();
|
|
|
|
|
|
|
|
BBtoRegionMap::iterator it = BBtoRegion.find(BB);
|
|
|
|
|
|
|
|
// This basic block is a start block of a region. It is already in the
|
|
|
|
// BBtoRegion relation. Only the child basic blocks have to be updated.
|
|
|
|
if (it != BBtoRegion.end()) {
|
2012-02-23 01:25:00 +08:00
|
|
|
Region *newRegion = it->second;
|
2010-07-22 15:46:31 +08:00
|
|
|
region->addSubRegion(getTopMostParent(newRegion));
|
|
|
|
region = newRegion;
|
|
|
|
} else {
|
|
|
|
BBtoRegion[BB] = region;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (DomTreeNode::iterator CI = N->begin(), CE = N->end(); CI != CE; ++CI)
|
|
|
|
buildRegionsTree(*CI, region);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RegionInfo::releaseMemory() {
|
|
|
|
BBtoRegion.clear();
|
|
|
|
if (TopLevelRegion)
|
|
|
|
delete TopLevelRegion;
|
2014-04-15 12:59:12 +08:00
|
|
|
TopLevelRegion = nullptr;
|
2010-07-22 15:46:31 +08:00
|
|
|
}
|
|
|
|
|
2010-08-07 02:33:48 +08:00
|
|
|
RegionInfo::RegionInfo() : FunctionPass(ID) {
|
2010-10-20 01:21:58 +08:00
|
|
|
initializeRegionInfoPass(*PassRegistry::getPassRegistry());
|
2014-04-15 12:59:12 +08:00
|
|
|
TopLevelRegion = nullptr;
|
2010-07-22 15:46:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
RegionInfo::~RegionInfo() {
|
|
|
|
releaseMemory();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RegionInfo::Calculate(Function &F) {
|
|
|
|
// ShortCut a function where for every BB the exit of the largest region
|
|
|
|
// starting with BB is stored. These regions can be threated as single BBS.
|
|
|
|
// This improves performance on linear CFGs.
|
|
|
|
BBtoBBMap ShortCut;
|
|
|
|
|
|
|
|
scanForRegions(F, &ShortCut);
|
|
|
|
BasicBlock *BB = &F.getEntryBlock();
|
|
|
|
buildRegionsTree(DT->getNode(BB), TopLevelRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RegionInfo::runOnFunction(Function &F) {
|
|
|
|
releaseMemory();
|
|
|
|
|
2014-01-13 21:07:17 +08:00
|
|
|
DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
|
2010-07-22 15:46:31 +08:00
|
|
|
PDT = &getAnalysis<PostDominatorTree>();
|
|
|
|
DF = &getAnalysis<DominanceFrontier>();
|
|
|
|
|
2014-04-15 12:59:12 +08:00
|
|
|
TopLevelRegion = new Region(&F.getEntryBlock(), nullptr, this, DT, nullptr);
|
2010-07-22 15:46:31 +08:00
|
|
|
updateStatistics(TopLevelRegion);
|
|
|
|
|
|
|
|
Calculate(F);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RegionInfo::getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.setPreservesAll();
|
2014-01-13 21:07:17 +08:00
|
|
|
AU.addRequiredTransitive<DominatorTreeWrapperPass>();
|
2010-07-22 15:46:31 +08:00
|
|
|
AU.addRequired<PostDominatorTree>();
|
|
|
|
AU.addRequired<DominanceFrontier>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RegionInfo::print(raw_ostream &OS, const Module *) const {
|
|
|
|
OS << "Region tree:\n";
|
2011-04-04 15:19:18 +08:00
|
|
|
TopLevelRegion->print(OS, true, 0, printStyle.getValue());
|
2010-07-22 15:46:31 +08:00
|
|
|
OS << "End region tree\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
void RegionInfo::verifyAnalysis() const {
|
|
|
|
// Only do verification when user wants to, otherwise this expensive check
|
|
|
|
// will be invoked by PMDataManager::verifyPreservedAnalysis when
|
|
|
|
// a regionpass (marked PreservedAll) finish.
|
|
|
|
if (!VerifyRegionInfo) return;
|
|
|
|
|
|
|
|
TopLevelRegion->verifyRegionNest();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Region pass manager support.
|
|
|
|
Region *RegionInfo::getRegionFor(BasicBlock *BB) const {
|
|
|
|
BBtoRegionMap::const_iterator I=
|
|
|
|
BBtoRegion.find(BB);
|
2014-04-15 12:59:12 +08:00
|
|
|
return I != BBtoRegion.end() ? I->second : nullptr;
|
2010-07-22 15:46:31 +08:00
|
|
|
}
|
|
|
|
|
2010-10-13 13:54:07 +08:00
|
|
|
void RegionInfo::setRegionFor(BasicBlock *BB, Region *R) {
|
|
|
|
BBtoRegion[BB] = R;
|
|
|
|
}
|
|
|
|
|
2010-07-22 15:46:31 +08:00
|
|
|
Region *RegionInfo::operator[](BasicBlock *BB) const {
|
|
|
|
return getRegionFor(BB);
|
|
|
|
}
|
|
|
|
|
2010-07-27 16:39:43 +08:00
|
|
|
BasicBlock *RegionInfo::getMaxRegionExit(BasicBlock *BB) const {
|
2014-04-15 12:59:12 +08:00
|
|
|
BasicBlock *Exit = nullptr;
|
2010-07-27 16:39:43 +08:00
|
|
|
|
|
|
|
while (true) {
|
|
|
|
// Get largest region that starts at BB.
|
|
|
|
Region *R = getRegionFor(BB);
|
|
|
|
while (R && R->getParent() && R->getParent()->getEntry() == BB)
|
|
|
|
R = R->getParent();
|
|
|
|
|
|
|
|
// Get the single exit of BB.
|
|
|
|
if (R && R->getEntry() == BB)
|
|
|
|
Exit = R->getExit();
|
|
|
|
else if (++succ_begin(BB) == succ_end(BB))
|
|
|
|
Exit = *succ_begin(BB);
|
|
|
|
else // No single exit exists.
|
|
|
|
return Exit;
|
|
|
|
|
|
|
|
// Get largest region that starts at Exit.
|
|
|
|
Region *ExitR = getRegionFor(Exit);
|
|
|
|
while (ExitR && ExitR->getParent()
|
|
|
|
&& ExitR->getParent()->getEntry() == Exit)
|
|
|
|
ExitR = ExitR->getParent();
|
|
|
|
|
|
|
|
for (pred_iterator PI = pred_begin(Exit), PE = pred_end(Exit); PI != PE;
|
|
|
|
++PI)
|
|
|
|
if (!R->contains(*PI) && !ExitR->contains(*PI))
|
|
|
|
break;
|
|
|
|
|
|
|
|
// This stops infinite cycles.
|
|
|
|
if (DT->dominates(Exit, BB))
|
|
|
|
break;
|
|
|
|
|
|
|
|
BB = Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Exit;
|
|
|
|
}
|
|
|
|
|
2010-07-22 15:46:31 +08:00
|
|
|
Region*
|
|
|
|
RegionInfo::getCommonRegion(Region *A, Region *B) const {
|
|
|
|
assert (A && B && "One of the Regions is NULL");
|
|
|
|
|
|
|
|
if (A->contains(B)) return A;
|
|
|
|
|
|
|
|
while (!B->contains(A))
|
|
|
|
B = B->getParent();
|
|
|
|
|
|
|
|
return B;
|
|
|
|
}
|
|
|
|
|
|
|
|
Region*
|
|
|
|
RegionInfo::getCommonRegion(SmallVectorImpl<Region*> &Regions) const {
|
|
|
|
Region* ret = Regions.back();
|
|
|
|
Regions.pop_back();
|
|
|
|
|
|
|
|
for (SmallVectorImpl<Region*>::const_iterator I = Regions.begin(),
|
|
|
|
E = Regions.end(); I != E; ++I)
|
|
|
|
ret = getCommonRegion(ret, *I);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
Region*
|
|
|
|
RegionInfo::getCommonRegion(SmallVectorImpl<BasicBlock*> &BBs) const {
|
|
|
|
Region* ret = getRegionFor(BBs.back());
|
|
|
|
BBs.pop_back();
|
|
|
|
|
|
|
|
for (SmallVectorImpl<BasicBlock*>::const_iterator I = BBs.begin(),
|
|
|
|
E = BBs.end(); I != E; ++I)
|
|
|
|
ret = getCommonRegion(ret, getRegionFor(*I));
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-10-13 13:54:13 +08:00
|
|
|
void RegionInfo::splitBlock(BasicBlock* NewBB, BasicBlock *OldBB)
|
|
|
|
{
|
|
|
|
Region *R = getRegionFor(OldBB);
|
2010-10-13 19:02:44 +08:00
|
|
|
|
2010-10-13 13:54:13 +08:00
|
|
|
setRegionFor(NewBB, R);
|
|
|
|
|
2010-10-13 19:02:44 +08:00
|
|
|
while (R->getEntry() == OldBB && !R->isTopLevelRegion()) {
|
2010-10-13 13:54:13 +08:00
|
|
|
R->replaceEntry(NewBB);
|
|
|
|
R = R->getParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
setRegionFor(OldBB, R);
|
|
|
|
}
|
|
|
|
|
2010-07-22 15:46:31 +08:00
|
|
|
char RegionInfo::ID = 0;
|
2010-10-13 03:48:12 +08:00
|
|
|
INITIALIZE_PASS_BEGIN(RegionInfo, "regions",
|
|
|
|
"Detect single entry single exit regions", true, true)
|
2014-01-13 21:07:17 +08:00
|
|
|
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
|
2010-10-13 03:48:12 +08:00
|
|
|
INITIALIZE_PASS_DEPENDENCY(PostDominatorTree)
|
|
|
|
INITIALIZE_PASS_DEPENDENCY(DominanceFrontier)
|
|
|
|
INITIALIZE_PASS_END(RegionInfo, "regions",
|
2010-10-08 06:25:06 +08:00
|
|
|
"Detect single entry single exit regions", true, true)
|
2010-07-22 15:46:31 +08:00
|
|
|
|
|
|
|
// Create methods available outside of this file, to use them
|
|
|
|
// "include/llvm/LinkAllPasses.h". Otherwise the pass would be deleted by
|
|
|
|
// the link time optimization.
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
FunctionPass *createRegionInfoPass() {
|
|
|
|
return new RegionInfo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|