[polly] r202707 - [C++11] Use foreach iterator for blocks and operands
Tobias Grosser
tobias at grosser.es
Mon Mar 3 05:13:55 PST 2014
Author: grosser
Date: Mon Mar 3 07:13:55 2014
New Revision: 202707
URL: http://llvm.org/viewvc/llvm-project?rev=202707&view=rev
Log:
[C++11] Use foreach iterator for blocks and operands
Modified:
polly/trunk/lib/Analysis/ScopDetection.cpp
polly/trunk/lib/Analysis/ScopGraphPrinter.cpp
polly/trunk/lib/Analysis/TempScopInfo.cpp
polly/trunk/lib/IndependentBlocks.cpp
Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=202707&r1=202706&r2=202707&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Mon Mar 3 07:13:55 2014
@@ -380,13 +380,9 @@ bool ScopDetection::isInvariant(const Va
if (isa<PHINode>(*I))
return false;
- // Check that all operands of the instruction are
- // themselves invariant.
- const Instruction::const_op_iterator OE = I->op_end();
- for (Instruction::const_op_iterator OI = I->op_begin(); OI != OE; ++OI) {
- if (!isInvariant(**OI, Reg))
+ for (const auto &Operand : I->operands())
+ if (!isInvariant(*Operand, Reg))
return false;
- }
// When the instruction is a load instruction, check that no write to memory
// in the region aliases with the load.
@@ -395,11 +391,9 @@ bool ScopDetection::isInvariant(const Va
const Region::const_block_iterator BE = Reg.block_end();
// Check if any basic block in the region can modify the location pointed to
// by 'Loc'. If so, 'Val' is (likely) not invariant in the region.
- for (Region::const_block_iterator BI = Reg.block_begin(); BI != BE; ++BI) {
- const BasicBlock &BB = **BI;
- if (AA->canBasicBlockModify(BB, Loc))
+ for (const auto &BB : Reg.blocks())
+ if (AA->canBasicBlockModify(*BB, Loc))
return false;
- }
}
return true;
@@ -592,9 +586,8 @@ Region *ScopDetection::expandRegion(Regi
return LastValidRegion;
}
static bool regionWithoutLoops(Region &R, LoopInfo *LI) {
- for (Region::block_iterator I = R.block_begin(), E = R.block_end(); I != E;
- ++I)
- if (R.contains(LI->getLoopFor(*I)))
+ for (const auto &BB : R.blocks())
+ if (R.contains(LI->getLoopFor(BB)))
return false;
return true;
@@ -671,22 +664,18 @@ void ScopDetection::findScops(Region &R)
bool ScopDetection::allBlocksValid(DetectionContext &Context) const {
Region &R = Context.CurRegion;
- for (Region::block_iterator I = R.block_begin(), E = R.block_end(); I != E;
- ++I) {
- Loop *L = LI->getLoopFor(*I);
- if (L && L->getHeader() == *I && !isValidLoop(L, Context))
+ for (const auto &BB : R.blocks()) {
+ Loop *L = LI->getLoopFor(BB);
+ if (L && L->getHeader() == BB && !isValidLoop(L, Context))
return false;
}
- for (Region::block_iterator I = R.block_begin(), E = R.block_end(); I != E;
- ++I)
- if (!isValidCFG(**I, Context))
+ for (const auto &BB : R.blocks())
+ if (!isValidCFG(*BB, Context))
return false;
- for (Region::block_iterator BI = R.block_begin(), E = R.block_end(); BI != E;
- ++BI)
- for (BasicBlock::iterator I = (*BI)->begin(), E = --(*BI)->end(); I != E;
- ++I)
+ for (const auto &BB : R.blocks())
+ for (BasicBlock::iterator I = BB->begin(), E = --BB->end(); I != E; ++I)
if (!isValidInstruction(*I, Context))
return false;
@@ -779,9 +768,8 @@ void ScopDetection::getDebugLocation(con
LineBegin = -1;
LineEnd = 0;
- for (Region::const_block_iterator RI = R->block_begin(), RE = R->block_end();
- RI != RE; ++RI)
- for (BasicBlock::iterator BI = (*RI)->begin(), BE = (*RI)->end(); BI != BE;
+ for (const auto &BB : R->blocks())
+ for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE;
++BI) {
DebugLoc DL = BI->getDebugLoc();
if (DL.isUnknown())
Modified: polly/trunk/lib/Analysis/ScopGraphPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopGraphPrinter.cpp?rev=202707&r1=202706&r2=202707&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopGraphPrinter.cpp (original)
+++ polly/trunk/lib/Analysis/ScopGraphPrinter.cpp Mon Mar 3 07:13:55 2014
@@ -139,18 +139,16 @@ struct DOTGraphTraits<ScopDetection *> :
O.indent(2 * (depth + 1)) << "color = " << color << "\n";
}
- for (Region::const_iterator RI = R->begin(), RE = R->end(); RI != RE; ++RI)
- printRegionCluster(SD, *RI, O, depth + 1);
+ for (const auto &SubRegion : *R)
+ printRegionCluster(SD, SubRegion, O, depth + 1);
RegionInfo *RI = R->getRegionInfo();
- for (Region::const_block_iterator BI = R->block_begin(),
- BE = R->block_end();
- BI != BE; ++BI)
- if (RI->getRegionFor(*BI) == R)
+ for (const auto &BB : R->blocks())
+ if (RI->getRegionFor(BB) == R)
O.indent(2 * (depth + 1))
<< "Node"
- << static_cast<void *>(RI->getTopLevelRegion()->getBBNode(*BI))
+ << static_cast<void *>(RI->getTopLevelRegion()->getBBNode(BB))
<< ";\n";
O.indent(2 * depth) << "}\n";
Modified: polly/trunk/lib/Analysis/TempScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/TempScopInfo.cpp?rev=202707&r1=202706&r2=202707&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/TempScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/TempScopInfo.cpp Mon Mar 3 07:13:55 2014
@@ -79,11 +79,7 @@ void TempScop::printDetail(raw_ostream &
const Region *CurR, unsigned ind) const {
// FIXME: Print other details rather than memory accesses.
- typedef Region::const_block_iterator bb_iterator;
- for (bb_iterator I = CurR->block_begin(), E = CurR->block_end(); I != E;
- ++I) {
- BasicBlock *CurBlock = *I;
-
+ for (const auto &CurBlock : CurR->blocks()) {
AccFuncMapType::const_iterator AccSetIt = AccFuncMap.find(CurBlock);
// Ignore trivial blocks that do not contain any memory access.
@@ -200,9 +196,8 @@ void TempScopInfo::buildLoopBounds(TempS
Region &R = Scop.getMaxRegion();
unsigned MaxLoopDepth = 0;
- for (Region::block_iterator I = R.block_begin(), E = R.block_end(); I != E;
- ++I) {
- Loop *L = LI->getLoopFor(*I);
+ for (auto const &BB : R.blocks()) {
+ Loop *L = LI->getLoopFor(BB);
if (!L || !R.contains(L))
continue;
@@ -307,10 +302,9 @@ void TempScopInfo::buildCondition(BasicB
TempScop *TempScopInfo::buildTempScop(Region &R) {
TempScop *TScop = new TempScop(R, LoopBounds, BBConds, AccFuncMap);
- for (Region::block_iterator I = R.block_begin(), E = R.block_end(); I != E;
- ++I) {
- buildAccessFunctions(R, **I);
- buildCondition(*I, R.getEntry());
+ for (const auto &BB : R.blocks()) {
+ buildAccessFunctions(R, *BB);
+ buildCondition(BB, R.getEntry());
}
buildLoopBounds(*TScop);
Modified: polly/trunk/lib/IndependentBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/IndependentBlocks.cpp?rev=202707&r1=202706&r2=202707&view=diff
==============================================================================
--- polly/trunk/lib/IndependentBlocks.cpp (original)
+++ polly/trunk/lib/IndependentBlocks.cpp Mon Mar 3 07:13:55 2014
@@ -264,9 +264,8 @@ bool IndependentBlocks::createIndependen
bool IndependentBlocks::createIndependentBlocks(const Region *R) {
bool Changed = false;
- for (Region::const_block_iterator SI = R->block_begin(), SE = R->block_end();
- SI != SE; ++SI)
- Changed |= createIndependentBlocks(*SI, R);
+ for (const auto &BB : R->blocks())
+ Changed |= createIndependentBlocks(BB, R);
return Changed;
}
@@ -275,9 +274,8 @@ bool IndependentBlocks::eliminateDeadCod
std::vector<Instruction *> WorkList;
// Find all trivially dead instructions.
- for (Region::const_block_iterator SI = R->block_begin(), SE = R->block_end();
- SI != SE; ++SI)
- for (BasicBlock::iterator I = (*SI)->begin(), E = (*SI)->end(); I != E; ++I)
+ for (const auto &BB : R->blocks())
+ for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
if (isInstructionTriviallyDead(I))
WorkList.push_back(I);
@@ -353,9 +351,8 @@ bool IndependentBlocks::splitExitBlock(R
bool IndependentBlocks::translateScalarToArray(const Region *R) {
bool Changed = false;
- for (Region::const_block_iterator SI = R->block_begin(), SE = R->block_end();
- SI != SE; ++SI)
- Changed |= translateScalarToArray(*SI, R);
+ for (const auto &BB : R->blocks())
+ Changed |= translateScalarToArray(BB, R);
return Changed;
}
@@ -495,9 +492,8 @@ bool IndependentBlocks::isIndependentBlo
}
bool IndependentBlocks::areAllBlocksIndependent(const Region *R) const {
- for (Region::const_block_iterator SI = R->block_begin(), SE = R->block_end();
- SI != SE; ++SI)
- if (!isIndependentBlock(R, *SI))
+ for (const auto &BB : R->blocks())
+ if (!isIndependentBlock(R, BB))
return false;
return true;
More information about the llvm-commits
mailing list