aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-05-04 20:55:23 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-05-04 20:55:23 +0000
commit7c52c97a2232756bbcc2fb4e664892bdb8b2d90c (patch)
treec461b6340583748ebfb69be0be481a94bc9c5211 /lib/Analysis
parent49683f3c961379fbc088871a5d6304950f1f1cbc (diff)
Rename the Region::block_iterator to Region::block_node_iterator, and
add a new Region::block_iterator which actually iterates over the basic blocks of the region. The old iterator, now call 'block_node_iterator' iterates over RegionNodes which contain a single basic block. This works well with the GraphTraits-based iterator design, however most users actually want an iterator over the BasicBlocks inside these RegionNodes. Now the 'block_iterator' is a wrapper which exposes exactly this interface. Internally it uses the block_node_iterator to walk all nodes which are single basic blocks, but transparently unwraps the basic block to make user code simpler. While this patch is a bit of a wash, most of the updates are to internal users, not external users of the RegionInfo. I have an accompanying patch to Polly that is a strict simplification of every user of this interface, and I'm working on a pass that also wants the same simplified interface. This patch alone should have no functional impact. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156202 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/RegionInfo.cpp30
-rw-r--r--lib/Analysis/RegionPass.cpp3
-rw-r--r--lib/Analysis/RegionPrinter.cpp8
3 files changed, 29 insertions, 12 deletions
diff --git a/lib/Analysis/RegionInfo.cpp b/lib/Analysis/RegionInfo.cpp
index b507b1e340..5f4458b402 100644
--- a/lib/Analysis/RegionInfo.cpp
+++ b/lib/Analysis/RegionInfo.cpp
@@ -47,7 +47,7 @@ static cl::opt<enum Region::PrintStyle> printStyle("print-region-style",
cl::values(
clEnumValN(Region::PrintNone, "none", "print no details"),
clEnumValN(Region::PrintBB, "bb",
- "print regions in detail with block_iterator"),
+ "print regions in detail with block_node_iterator"),
clEnumValN(Region::PrintRN, "rn",
"print regions in detail with element_iterator"),
clEnumValEnd));
@@ -246,22 +246,38 @@ void Region::verifyRegionNest() const {
verifyRegion();
}
-Region::block_iterator Region::block_begin() {
+Region::block_node_iterator Region::block_node_begin() {
return GraphTraits<FlatIt<Region*> >::nodes_begin(this);
}
-Region::block_iterator Region::block_end() {
+Region::block_node_iterator Region::block_node_end() {
return GraphTraits<FlatIt<Region*> >::nodes_end(this);
}
-Region::const_block_iterator Region::block_begin() const {
+Region::const_block_node_iterator Region::block_node_begin() const {
return GraphTraits<FlatIt<const Region*> >::nodes_begin(this);
}
-Region::const_block_iterator Region::block_end() const {
+Region::const_block_node_iterator Region::block_node_end() const {
return GraphTraits<FlatIt<const Region*> >::nodes_end(this);
}
+Region::block_iterator Region::block_begin() {
+ return block_node_begin();
+}
+
+Region::block_iterator Region::block_end() {
+ return block_node_end();
+}
+
+Region::const_block_iterator Region::block_begin() const {
+ return block_node_begin();
+}
+
+Region::const_block_iterator Region::block_end() const {
+ return block_node_end();
+}
+
Region::element_iterator Region::element_begin() {
return GraphTraits<Region*>::nodes_begin(this);
}
@@ -425,7 +441,9 @@ void Region::print(raw_ostream &OS, bool print_tree, unsigned level,
OS.indent(level*2 + 2);
if (Style == PrintBB) {
- for (const_block_iterator I = block_begin(), E = block_end(); I!=E; ++I)
+ for (const_block_node_iterator I = block_node_begin(),
+ E = block_node_end();
+ I != E; ++I)
OS << **I << ", "; // TODO: remove the last ","
} else if (Style == PrintRN) {
for (const_element_iterator I = element_begin(), E = element_end(); I!=E; ++I)
diff --git a/lib/Analysis/RegionPass.cpp b/lib/Analysis/RegionPass.cpp
index 3a3529baf9..c97b5ebd7d 100644
--- a/lib/Analysis/RegionPass.cpp
+++ b/lib/Analysis/RegionPass.cpp
@@ -195,7 +195,8 @@ public:
virtual bool runOnRegion(Region *R, RGPassManager &RGM) {
Out << Banner;
- for (Region::block_iterator I = R->block_begin(), E = R->block_end();
+ for (Region::block_node_iterator I = R->block_node_begin(),
+ E = R->block_node_end();
I != E; ++I)
(*I)->getEntry()->print(Out);
diff --git a/lib/Analysis/RegionPrinter.cpp b/lib/Analysis/RegionPrinter.cpp
index a1730b0a3c..8b23cc7042 100644
--- a/lib/Analysis/RegionPrinter.cpp
+++ b/lib/Analysis/RegionPrinter.cpp
@@ -122,13 +122,11 @@ struct DOTGraphTraits<RegionInfo*> : public DOTGraphTraits<RegionNode*> {
RegionInfo *RI = R->getRegionInfo();
for (Region::const_block_iterator BI = R->block_begin(),
- BE = R->block_end(); BI != BE; ++BI) {
- BasicBlock *BB = (*BI)->getNodeAs<BasicBlock>();
- if (RI->getRegionFor(BB) == R)
+ BE = R->block_end(); BI != BE; ++BI)
+ if (RI->getRegionFor(*BI) == R)
O.indent(2 * (depth + 1)) << "Node"
- << static_cast<const void*>(RI->getTopLevelRegion()->getBBNode(BB))
+ << static_cast<const void*>(RI->getTopLevelRegion()->getBBNode(*BI))
<< ";\n";
- }
O.indent(2 * depth) << "}\n";
}