summaryrefslogtreecommitdiffstats
path: root/polly/lib/RegionSimplify.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'polly/lib/RegionSimplify.cpp')
-rw-r--r--polly/lib/RegionSimplify.cpp66
1 files changed, 33 insertions, 33 deletions
diff --git a/polly/lib/RegionSimplify.cpp b/polly/lib/RegionSimplify.cpp
index 8d897b1698e..abf8aee588e 100644
--- a/polly/lib/RegionSimplify.cpp
+++ b/polly/lib/RegionSimplify.cpp
@@ -33,7 +33,7 @@ STATISTIC(NumEntries, "The # of created entry edges");
STATISTIC(NumExits, "The # of created exit edges");
namespace {
-class RegionSimplify: public RegionPass {
+class RegionSimplify : public RegionPass {
// Remember the modified region.
Region *r;
void createSingleEntryEdge(Region *R);
@@ -51,21 +51,13 @@ public:
char RegionSimplify::ID = 0;
-INITIALIZE_PASS_BEGIN(RegionSimplify, "polly-region-simplify",
- "Transform refined regions into simple regions", false,
- false)
-INITIALIZE_PASS_DEPENDENCY(RegionInfo)
-INITIALIZE_PASS_END(RegionSimplify, "polly-region-simplify",
- "Transform refined regions into simple regions", false,
- false)
namespace polly {
- Pass *createRegionSimplifyPass() {
- return new RegionSimplify();
- }
+Pass *createRegionSimplifyPass() { return new RegionSimplify(); }
}
void RegionSimplify::print(raw_ostream &O, const Module *M) const {
- if (r == 0) return;
+ if (r == 0)
+ return;
BasicBlock *enteringBlock = r->getEnteringBlock();
BasicBlock *exitingBlock = r->getExitingBlock();
@@ -92,19 +84,19 @@ void RegionSimplify::getAnalysisUsage(AnalysisUsage &AU) const {
// Function SplitBlockPredecessors currently updates/preserves AliasAnalysis,
/// DominatorTree, LoopInfo, and LCCSA but no other analyses.
//AU.addPreserved<AliasAnalysis>(); Break SCEV-AA
- AU.addPreserved<DominatorTree> ();
+ AU.addPreserved<DominatorTree>();
AU.addPreserved<LoopInfo>();
AU.addPreservedID(LCSSAID);
- AU.addPreserved<RegionInfo> ();
- AU.addRequired<RegionInfo> ();
+ AU.addPreserved<RegionInfo>();
+ AU.addRequired<RegionInfo>();
}
// createSingleEntryEdge - Split the entry basic block of the given
// region after the last PHINode to form a single entry edge.
void RegionSimplify::createSingleEntryEdge(Region *R) {
BasicBlock *oldEntry = R->getEntry();
- SmallVector<BasicBlock*, 4> Preds;
+ SmallVector<BasicBlock *, 4> Preds;
for (pred_iterator PI = pred_begin(oldEntry), PE = pred_end(oldEntry);
PI != PE; ++PI)
if (!R->contains(*PI))
@@ -112,10 +104,10 @@ void RegionSimplify::createSingleEntryEdge(Region *R) {
assert(Preds.size() && "This region has already a single entry edge");
- BasicBlock *newEntry = SplitBlockPredecessors(oldEntry, Preds,
- ".single_entry", this);
+ BasicBlock *newEntry =
+ SplitBlockPredecessors(oldEntry, Preds, ".single_entry", this);
- RegionInfo *RI = &getAnalysis<RegionInfo> ();
+ RegionInfo *RI = &getAnalysis<RegionInfo>();
// We do not update entry node for children of this region.
// This make it easier to extract children regions because they do not share
// the entry node with their parents.
@@ -123,7 +115,7 @@ void RegionSimplify::createSingleEntryEdge(Region *R) {
Region *r = R->getParent();
// Put the new entry to R's parent.
- RI->setRegionFor(newEntry,r);
+ RI->setRegionFor(newEntry, r);
while (r->getEntry() == oldEntry && !r->isTopLevelRegion()) {
r->replaceEntry(newEntry);
@@ -137,11 +129,11 @@ void RegionSimplify::createSingleEntryEdge(Region *R) {
std::vector<Region *> RQ;
RQ.push_back(r);
- while (!RQ.empty()){
+ while (!RQ.empty()) {
r = RQ.back();
RQ.pop_back();
- for (Region::const_iterator RI = r->begin(), RE = r->end(); RI!=RE; ++RI)
+ for (Region::const_iterator RI = r->begin(), RE = r->end(); RI != RE; ++RI)
RQ.push_back(*RI);
if (r->getExit() == oldEntry && !R->contains(r))
@@ -155,37 +147,37 @@ void RegionSimplify::createSingleEntryEdge(Region *R) {
void RegionSimplify::createSingleExitEdge(Region *R) {
BasicBlock *oldExit = R->getExit();
- SmallVector<BasicBlock*, 4> Preds;
- for (pred_iterator PI = pred_begin(oldExit), PE = pred_end(oldExit);
- PI != PE; ++PI)
+ SmallVector<BasicBlock *, 4> Preds;
+ for (pred_iterator PI = pred_begin(oldExit), PE = pred_end(oldExit); PI != PE;
+ ++PI)
if (R->contains(*PI))
Preds.push_back(*PI);
DEBUG(dbgs() << "Going to create single exit for:\n");
DEBUG(R->print(dbgs(), true, 0, Region::PrintRN));
- BasicBlock *newExit = SplitBlockPredecessors(oldExit, Preds,
- ".single_exit", this);
+ BasicBlock *newExit =
+ SplitBlockPredecessors(oldExit, Preds, ".single_exit", this);
RegionInfo *RI = &getAnalysis<RegionInfo>();
// We do not need to update entry nodes because this split happens inside
// this region and it affects only this region and all of its children.
// The new split node belongs to this region
- RI->setRegionFor(newExit,R);
+ RI->setRegionFor(newExit, R);
DEBUG(dbgs() << "Adding new exiting block: " << newExit->getName() << '\n');
// all children of this region whose exit is oldExit is changed to newExit
std::vector<Region *> RQ;
- for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; ++RI)
+ for (Region::const_iterator RI = R->begin(), RE = R->end(); RI != RE; ++RI)
RQ.push_back(*RI);
- while (!RQ.empty()){
+ while (!RQ.empty()) {
R = RQ.back();
RQ.pop_back();
if (R->getExit() != oldExit)
continue;
- for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; ++RI)
+ for (Region::const_iterator RI = R->begin(), RE = R->end(); RI != RE; ++RI)
RQ.push_back(*RI);
R->replaceExit(newExit);
@@ -203,8 +195,8 @@ bool RegionSimplify::runOnRegion(Region *R, RGPassManager &RGM) {
if (!R->isTopLevelRegion()) {
// split entry node if the region has multiple entry edges
- if (!(R->getEnteringBlock())
- && (pred_begin(R->getEntry()) != pred_end(R->getEntry()))) {
+ if (!(R->getEnteringBlock()) &&
+ (pred_begin(R->getEntry()) != pred_end(R->getEntry()))) {
createSingleEntryEdge(R);
r = R;
++NumEntries;
@@ -220,3 +212,11 @@ bool RegionSimplify::runOnRegion(Region *R, RGPassManager &RGM) {
return r != 0;
}
+
+INITIALIZE_PASS_BEGIN(RegionSimplify, "polly-region-simplify",
+ "Transform refined regions into simple regions", false,
+ false);
+INITIALIZE_PASS_DEPENDENCY(RegionInfo);
+INITIALIZE_PASS_END(RegionSimplify, "polly-region-simplify",
+ "Transform refined regions into simple regions", false,
+ false)
OpenPOWER on IntegriCloud