mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[C++11] Add a basic block range view for RegionInfo
This also switches the users in LLVM to ensure this functionality is tested. llvm-svn: 202705
This commit is contained in:
parent
be5c3e764d
commit
8d3b137235
@ -27,6 +27,7 @@
|
|||||||
#ifndef LLVM_ANALYSIS_REGIONINFO_H
|
#ifndef LLVM_ANALYSIS_REGIONINFO_H
|
||||||
#define LLVM_ANALYSIS_REGIONINFO_H
|
#define LLVM_ANALYSIS_REGIONINFO_H
|
||||||
|
|
||||||
|
#include "llvm/ADT/iterator_range.h"
|
||||||
#include "llvm/ADT/PointerIntPair.h"
|
#include "llvm/ADT/PointerIntPair.h"
|
||||||
#include "llvm/Analysis/DominanceFrontier.h"
|
#include "llvm/Analysis/DominanceFrontier.h"
|
||||||
#include "llvm/Analysis/PostDominators.h"
|
#include "llvm/Analysis/PostDominators.h"
|
||||||
@ -545,6 +546,21 @@ public:
|
|||||||
const_block_iterator block_end() const {
|
const_block_iterator block_end() const {
|
||||||
return const_block_iterator();
|
return const_block_iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef iterator_range<block_iterator> block_range;
|
||||||
|
typedef iterator_range<const_block_iterator> const_block_range;
|
||||||
|
|
||||||
|
/// @brief Returns a range view of the basic blocks in the region.
|
||||||
|
inline block_range blocks() {
|
||||||
|
return block_range(block_begin(), block_end());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief Returns a range view of the basic blocks in the region.
|
||||||
|
///
|
||||||
|
/// This is the 'const' version of the range view.
|
||||||
|
inline const_block_range blocks() const {
|
||||||
|
return const_block_range(block_begin(), block_end());
|
||||||
|
}
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/// @name Element Iterators
|
/// @name Element Iterators
|
||||||
|
@ -438,8 +438,8 @@ void Region::print(raw_ostream &OS, bool print_tree, unsigned level,
|
|||||||
OS.indent(level*2 + 2);
|
OS.indent(level*2 + 2);
|
||||||
|
|
||||||
if (Style == PrintBB) {
|
if (Style == PrintBB) {
|
||||||
for (const_block_iterator I = block_begin(), E = block_end(); I != E; ++I)
|
for (const auto &BB : blocks())
|
||||||
OS << (*I)->getName() << ", "; // TODO: remove the last ","
|
OS << BB->getName() << ", "; // TODO: remove the last ","
|
||||||
} else if (Style == PrintRN) {
|
} else if (Style == PrintRN) {
|
||||||
for (const_element_iterator I = element_begin(), E = element_end(); I!=E; ++I)
|
for (const_element_iterator I = element_begin(), E = element_end(); I!=E; ++I)
|
||||||
OS << **I << ", "; // TODO: remove the last ",
|
OS << **I << ", "; // TODO: remove the last ",
|
||||||
|
@ -195,9 +195,8 @@ public:
|
|||||||
|
|
||||||
virtual bool runOnRegion(Region *R, RGPassManager &RGM) {
|
virtual bool runOnRegion(Region *R, RGPassManager &RGM) {
|
||||||
Out << Banner;
|
Out << Banner;
|
||||||
for (Region::block_iterator I = R->block_begin(), E = R->block_end();
|
for (const auto &BB : R->blocks())
|
||||||
I != E; ++I)
|
BB->print(Out);
|
||||||
(*I)->print(Out);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -121,11 +121,10 @@ struct DOTGraphTraits<RegionInfo*> : public DOTGraphTraits<RegionNode*> {
|
|||||||
|
|
||||||
RegionInfo *RI = R->getRegionInfo();
|
RegionInfo *RI = R->getRegionInfo();
|
||||||
|
|
||||||
for (Region::const_block_iterator BI = R->block_begin(),
|
for (const auto &BB : R->blocks())
|
||||||
BE = R->block_end(); BI != BE; ++BI)
|
if (RI->getRegionFor(BB) == R)
|
||||||
if (RI->getRegionFor(*BI) == R)
|
|
||||||
O.indent(2 * (depth + 1)) << "Node"
|
O.indent(2 * (depth + 1)) << "Node"
|
||||||
<< static_cast<const void*>(RI->getTopLevelRegion()->getBBNode(*BI))
|
<< static_cast<const void*>(RI->getTopLevelRegion()->getBBNode(BB))
|
||||||
<< ";\n";
|
<< ";\n";
|
||||||
|
|
||||||
O.indent(2 * depth) << "}\n";
|
O.indent(2 * depth) << "}\n";
|
||||||
|
@ -829,11 +829,7 @@ void StructurizeCFG::createFlow() {
|
|||||||
/// no longer dominate all their uses. Not sure if this is really nessasary
|
/// no longer dominate all their uses. Not sure if this is really nessasary
|
||||||
void StructurizeCFG::rebuildSSA() {
|
void StructurizeCFG::rebuildSSA() {
|
||||||
SSAUpdater Updater;
|
SSAUpdater Updater;
|
||||||
for (Region::block_iterator I = ParentRegion->block_begin(),
|
for (const auto &BB : ParentRegion->blocks())
|
||||||
E = ParentRegion->block_end();
|
|
||||||
I != E; ++I) {
|
|
||||||
|
|
||||||
BasicBlock *BB = *I;
|
|
||||||
for (BasicBlock::iterator II = BB->begin(), IE = BB->end();
|
for (BasicBlock::iterator II = BB->begin(), IE = BB->end();
|
||||||
II != IE; ++II) {
|
II != IE; ++II) {
|
||||||
|
|
||||||
@ -865,7 +861,6 @@ void StructurizeCFG::rebuildSSA() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// \brief Run the transformation for each region found
|
/// \brief Run the transformation for each region found
|
||||||
bool StructurizeCFG::runOnRegion(Region *R, RGPassManager &RGM) {
|
bool StructurizeCFG::runOnRegion(Region *R, RGPassManager &RGM) {
|
||||||
|
Loading…
Reference in New Issue
Block a user