[polly] r203381 - [C++11] Update to reflect the Value::use_iterator and

Chandler Carruth chandlerc at gmail.com
Sun Mar 9 00:29:30 PST 2014


Author: chandlerc
Date: Sun Mar  9 03:29:29 2014
New Revision: 203381

URL: http://llvm.org/viewvc/llvm-project?rev=203381&view=rev
Log:
[C++11] Update to reflect the Value::use_iterator and
Value::user_iterator changes in LLVM r203364. Converts several of these
loops to nice range based loops in the process.

Built and tested cleanly for me, yay for being able to fully build and
test Polly changes!

Modified:
    polly/trunk/lib/Analysis/TempScopInfo.cpp
    polly/trunk/lib/IndVarSimplify.cpp
    polly/trunk/lib/IndependentBlocks.cpp

Modified: polly/trunk/lib/Analysis/TempScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/TempScopInfo.cpp?rev=203381&r1=203380&r2=203381&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/TempScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/TempScopInfo.cpp Sun Mar  9 03:29:29 2014
@@ -105,15 +105,14 @@ bool TempScopInfo::buildScalarDependence
   bool AnyCrossStmtUse = false;
   BasicBlock *ParentBB = Inst->getParent();
 
-  for (Instruction::use_iterator UI = Inst->use_begin(), UE = Inst->use_end();
-       UI != UE; ++UI) {
-    Instruction *U = dyn_cast<Instruction>(*UI);
+  for (User *U : Inst->users()) {
+    Instruction *UI = dyn_cast<Instruction>(U);
 
     // Ignore the strange user
-    if (U == 0)
+    if (UI == 0)
       continue;
 
-    BasicBlock *UseParent = U->getParent();
+    BasicBlock *UseParent = UI->getParent();
 
     // Ignore the users in the same BB (statement)
     if (UseParent == ParentBB)
@@ -121,7 +120,7 @@ bool TempScopInfo::buildScalarDependence
 
     // No need to translate these scalar dependences into polyhedral form,
     // because synthesizable scalars can be generated by the code generator.
-    if (canSynthesize(U, LI, SE, R))
+    if (canSynthesize(UI, LI, SE, R))
       continue;
 
     // Now U is used in another statement.
@@ -131,12 +130,12 @@ bool TempScopInfo::buildScalarDependence
     if (!R->contains(UseParent))
       continue;
 
-    assert(!isa<PHINode>(U) && "Non synthesizable PHINode found in a SCoP!");
+    assert(!isa<PHINode>(UI) && "Non synthesizable PHINode found in a SCoP!");
 
     // Use the def instruction as base address of the IRAccess, so that it will
     // become the name of the scalar access in the polyhedral form.
     IRAccess ScalarAccess(IRAccess::SCALARREAD, Inst, ZeroOffset, 1, true);
-    AccFuncMap[UseParent].push_back(std::make_pair(ScalarAccess, U));
+    AccFuncMap[UseParent].push_back(std::make_pair(ScalarAccess, UI));
   }
 
   return AnyCrossStmtUse;

Modified: polly/trunk/lib/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/IndVarSimplify.cpp?rev=203381&r1=203380&r2=203381&view=diff
==============================================================================
--- polly/trunk/lib/IndVarSimplify.cpp (original)
+++ polly/trunk/lib/IndVarSimplify.cpp Sun Mar  9 03:29:29 2014
@@ -262,12 +262,12 @@ void PollyIndVarSimplify::HandleFloating
 
   // Check Incr uses. One user is PN and the other user is an exit condition
   // used by the conditional terminator.
-  Value::use_iterator IncrUse = Incr->use_begin();
+  Value::user_iterator IncrUse = Incr->user_begin();
   Instruction *U1 = cast<Instruction>(*IncrUse++);
-  if (IncrUse == Incr->use_end())
+  if (IncrUse == Incr->user_end())
     return;
   Instruction *U2 = cast<Instruction>(*IncrUse++);
-  if (IncrUse != Incr->use_end())
+  if (IncrUse != Incr->user_end())
     return;
 
   // Find exit condition, which is an fcmp.  If it doesn't exist, or if it isn't
@@ -276,10 +276,10 @@ void PollyIndVarSimplify::HandleFloating
   if (!Compare)
     Compare = dyn_cast<FCmpInst>(U2);
   if (Compare == 0 || !Compare->hasOneUse() ||
-      !isa<BranchInst>(Compare->use_back()))
+      !isa<BranchInst>(Compare->user_back()))
     return;
 
-  BranchInst *TheBr = cast<BranchInst>(Compare->use_back());
+  BranchInst *TheBr = cast<BranchInst>(Compare->user_back());
 
   // We need to verify that the branch actually controls the iteration count
   // of the loop.  If not, the new IV can overflow and no one will notice.
@@ -1084,16 +1084,14 @@ Instruction *WidenIV::WidenIVUse(NarrowI
 /// pushNarrowIVUsers - Add eligible users of NarrowDef to NarrowIVUsers.
 ///
 void WidenIV::pushNarrowIVUsers(Instruction *NarrowDef, Instruction *WideDef) {
-  for (Value::use_iterator UI = NarrowDef->use_begin(),
-                           UE = NarrowDef->use_end();
-       UI != UE; ++UI) {
-    Instruction *NarrowUse = cast<Instruction>(*UI);
+  for (User *U : NarrowDef->users()) {
+    Instruction *NarrowUser = cast<Instruction>(U);
 
     // Handle data flow merges and bizarre phi cycles.
-    if (!Widened.insert(NarrowUse))
+    if (!Widened.insert(NarrowUser))
       continue;
 
-    NarrowIVUsers.push_back(NarrowIVDefUse(NarrowDef, NarrowUse, WideDef));
+    NarrowIVUsers.push_back(NarrowIVDefUse(NarrowDef, NarrowUser, WideDef));
   }
 }
 
@@ -1436,17 +1434,14 @@ static bool AlmostDeadIV(PHINode *Phi, B
   int LatchIdx = Phi->getBasicBlockIndex(LatchBlock);
   Value *IncV = Phi->getIncomingValue(LatchIdx);
 
-  for (Value::use_iterator UI = Phi->use_begin(), UE = Phi->use_end(); UI != UE;
-       ++UI) {
-    if (*UI != Cond && *UI != IncV)
+  for (User *U : Phi->users())
+    if (U != Cond && U != IncV)
       return false;
-  }
 
-  for (Value::use_iterator UI = IncV->use_begin(), UE = IncV->use_end();
-       UI != UE; ++UI) {
-    if (*UI != Cond && *UI != Phi)
+  for (User *U : IncV->users())
+    if (U != Cond && U != Phi)
       return false;
-  }
+
   return true;
 }
 
@@ -1747,12 +1742,11 @@ void PollyIndVarSimplify::SinkUnusedInva
     // Determine if there is a use in or before the loop (direct or
     // otherwise).
     bool UsedInLoop = false;
-    for (Value::use_iterator UI = I->use_begin(), UE = I->use_end(); UI != UE;
-         ++UI) {
-      User *U = *UI;
-      BasicBlock *UseBB = cast<Instruction>(U)->getParent();
-      if (PHINode *P = dyn_cast<PHINode>(U)) {
-        unsigned i = PHINode::getIncomingValueNumForOperand(UI.getOperandNo());
+    for (Use &U : I->uses()) {
+      Instruction *UI = cast<Instruction>(U.getUser());
+      BasicBlock *UseBB = UI->getParent();
+      if (PHINode *P = dyn_cast<PHINode>(UI)) {
+        unsigned i = PHINode::getIncomingValueNumForOperand(U.getOperandNo());
         UseBB = P->getIncomingBlock(i);
       }
       if (UseBB == Preheader || L->contains(UseBB)) {

Modified: polly/trunk/lib/IndependentBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/IndependentBlocks.cpp?rev=203381&r1=203380&r2=203381&view=diff
==============================================================================
--- polly/trunk/lib/IndependentBlocks.cpp (original)
+++ polly/trunk/lib/IndependentBlocks.cpp Sun Mar  9 03:29:29 2014
@@ -359,10 +359,9 @@ bool IndependentBlocks::translateScalarT
 
 // Returns true when Inst is only used inside region R.
 bool IndependentBlocks::onlyUsedInRegion(Instruction *Inst, const Region *R) {
-  for (Instruction::use_iterator UI = Inst->use_begin(), UE = Inst->use_end();
-       UI != UE; ++UI)
-    if (Instruction *U = dyn_cast<Instruction>(*UI))
-      if (isEscapeUse(U, R))
+  for (User *U : Inst->users())
+    if (Instruction *UI = dyn_cast<Instruction>(U))
+      if (isEscapeUse(UI, R))
         return false;
 
   return true;
@@ -374,22 +373,21 @@ bool IndependentBlocks::translateScalarT
     return false;
 
   SmallVector<Instruction *, 4> LoadInside, LoadOutside;
-  for (Instruction::use_iterator UI = Inst->use_begin(), UE = Inst->use_end();
-       UI != UE; ++UI)
+  for (User *U : Inst->users())
     // Inst is referenced outside or referenced as an escaped operand.
-    if (Instruction *U = dyn_cast<Instruction>(*UI)) {
-      if (isEscapeUse(U, R))
-        LoadOutside.push_back(U);
+    if (Instruction *UI = dyn_cast<Instruction>(U)) {
+      if (isEscapeUse(UI, R))
+        LoadOutside.push_back(UI);
 
       if (DisableIntraScopScalarToArray)
         continue;
 
-      if (canSynthesize(U, LI, SE, R))
+      if (canSynthesize(UI, LI, SE, R))
         continue;
 
-      BasicBlock *UParent = U->getParent();
+      BasicBlock *UParent = UI->getParent();
       if (R->contains(UParent) && isEscapeOperand(Inst, UParent, R))
-        LoadInside.push_back(U);
+        LoadInside.push_back(UI);
     }
 
   if (LoadOutside.empty() && LoadInside.empty())
@@ -458,9 +456,8 @@ bool IndependentBlocks::isIndependentBlo
       continue;
 
     // A value inside the Scop is referenced outside.
-    for (Instruction::use_iterator UI = Inst->use_begin(), UE = Inst->use_end();
-         UI != UE; ++UI) {
-      if (isEscapeUse(*UI, R)) {
+    for (User *U : Inst->users()) {
+      if (isEscapeUse(U, R)) {
         DEBUG(dbgs() << "Instruction not independent:\n");
         DEBUG(dbgs() << "Instruction used outside the Scop!\n");
         DEBUG(Inst->print(dbgs()));





More information about the llvm-commits mailing list