Use empty() instead of begin() == end().
authorDan Gohman <gohman@apple.com>
Thu, 14 Aug 2008 18:13:49 +0000 (18:13 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 14 Aug 2008 18:13:49 +0000 (18:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54780 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/LoopInfo.h
include/llvm/CodeGen/MachineLoopInfo.h
lib/CodeGen/LiveInterval.cpp
lib/CodeGen/LoopAligner.cpp
lib/CodeGen/SimpleRegisterCoalescing.cpp
lib/CodeGen/StrongPHIElimination.cpp
lib/Transforms/IPO/LoopExtractor.cpp
lib/Transforms/Scalar/LoopIndexSplit.cpp
lib/Transforms/Utils/SimplifyCFG.cpp

index e22f22f0702dcd7144884fa6499071840a83535d..1b684d73d3ca8c85aeedfffafd4484f5a6deb706 100644 (file)
@@ -648,6 +648,7 @@ public:
   typedef typename std::vector<LoopBase<BlockT>*>::const_iterator iterator;
   iterator begin() const { return TopLevelLoops.begin(); }
   iterator end() const { return TopLevelLoops.end(); }
+  bool empty() const { return TopLevelLoops.empty(); }
   
   /// getLoopFor - Return the inner most loop that BB lives in.  If a basic
   /// block is in no loop (for example the entry node), null is returned.
@@ -947,6 +948,7 @@ public:
   typedef std::vector<Loop*>::const_iterator iterator;
   inline iterator begin() const { return LI->begin(); }
   inline iterator end() const { return LI->end(); }
+  bool empty() const { return LI->empty(); }
 
   /// getLoopFor - Return the inner most loop that BB lives in.  If a basic
   /// block is in no loop (for example the entry node), null is returned.
index 8b46825f2570b55a57efb358e00a728326ae32f8..fa2d2290e31df3607433cdc3031416c2554f07a3 100644 (file)
@@ -92,6 +92,7 @@ public:
   typedef std::vector<MachineLoop*>::const_iterator iterator;
   inline iterator begin() const { return LI->begin(); }
   inline iterator end() const { return LI->end(); }
+  bool empty() const { return LI->empty(); }
 
   /// getLoopFor - Return the inner most loop that BB lives in.  If a basic
   /// block is in no loop (for example the entry node), null is returned.
index 0f5de9257a71959db4bb67e3743a9d0638c28692..ff430d71c7d79247424a406ae98202990f42c53e 100644 (file)
@@ -547,7 +547,7 @@ void LiveInterval::MergeValueInAsValue(const LiveInterval &RHS,
 /// used with an unknown definition value.
 void LiveInterval::MergeInClobberRanges(const LiveInterval &Clobbers,
                                         BumpPtrAllocator &VNInfoAllocator) {
-  if (Clobbers.begin() == Clobbers.end()) return;
+  if (Clobbers.empty()) return;
   
   // Find a value # to use for the clobber ranges.  If there is already a value#
   // for unknown values, use it.
index 1888391d5e7145aed221d3565e5ee657e85adc25..44f5bb461dc0650927e49d7decf45c18a3de8981 100644 (file)
@@ -46,7 +46,7 @@ FunctionPass *llvm::createLoopAlignerPass() { return new LoopAligner(); }
 bool LoopAligner::runOnMachineFunction(MachineFunction &MF) {
   const MachineLoopInfo *MLI = &getAnalysis<MachineLoopInfo>();
 
-  if (MLI->begin() == MLI->end())
+  if (MLI->empty())
     return false;  // No loops.
 
   const TargetLowering *TLI = MF.getTarget().getTargetLowering();
index b3e3409da3401ae388e5b61812501217e7188fa6..72db79dee4a9249e43cc4f0559736d74b2c3209e 100644 (file)
@@ -1852,7 +1852,7 @@ void SimpleRegisterCoalescing::joinIntervals() {
     JoinQueue = new JoinPriorityQueue<CopyRecSort>(this);
 
   std::vector<CopyRec> TryAgainList;
-  if (loopInfo->begin() == loopInfo->end()) {
+  if (loopInfo->empty()) {
     // If there are no loops in the function, join intervals in function order.
     for (MachineFunction::iterator I = mf_->begin(), E = mf_->end();
          I != E; ++I)
@@ -2049,7 +2049,7 @@ SimpleRegisterCoalescing::TurnCopyIntoImpDef(MachineBasicBlock::iterator &I,
   CopyMI->setDesc(tii_->get(TargetInstrInfo::IMPLICIT_DEF));
   for (int i = CopyMI->getNumOperands() - 1, e = 0; i > e; --i)
     CopyMI->RemoveOperand(i);
-  bool NoUse = mri_->use_begin(SrcReg) == mri_->use_end();
+  bool NoUse = mri_->use_empty(SrcReg);
   if (NoUse) {
     for (MachineRegisterInfo::reg_iterator I = mri_->reg_begin(SrcReg),
            E = mri_->reg_end(); I != E; ) {
index 37f54ce93a79b9df775a513bb89e2cc6a30ae303..9f59417b5dc0e05dec1315204806c02baed4b40b 100644 (file)
@@ -848,7 +848,7 @@ void StrongPHIElimination::mergeLiveIntervals(unsigned primary,
     RHS.removeValNo(*VI);
   }
   
-  if (RHS.begin() == RHS.end())
+  if (RHS.empty())
     LI.removeInterval(RHS.reg);
 }
 
index 10ec3065af7ca81ecbb640aac141f2ef4352a215..8e55b3f09192142a0cbedf2e1a3253e578bc3efe 100644 (file)
@@ -79,7 +79,7 @@ bool LoopExtractor::runOnFunction(Function &F) {
   LoopInfo &LI = getAnalysis<LoopInfo>();
 
   // If this function has no loops, there is nothing to do.
-  if (LI.begin() == LI.end())
+  if (LI.empty())
     return false;
 
   DominatorTree &DT = getAnalysis<DominatorTree>();
index 135ce33ee6f4918c9487ee12ede6f1f7f44047fb..1ab9a18cf6f2ae2a183bb8f3930d82dde3a3c4b5 100644 (file)
@@ -1006,9 +1006,9 @@ bool LoopIndexSplit::updateLoopIterationSpace(SplitInfo &SD) {
 
   // Remove split condition.
   SD.SplitCondition->eraseFromParent();
-  if (Op0->use_begin() == Op0->use_end())
+  if (Op0->use_empty())
     Op0->eraseFromParent();
-  if (Op1->use_begin() == Op1->use_end())
+  if (Op1->use_empty())
     Op1->eraseFromParent();
       
   BranchInst *ExitInsn =
index d04fce6892af188032c6fc1f31cb44058752644b..efd17650f2da3f6c676ccba6a23b181f408cd3be 100644 (file)
@@ -107,7 +107,7 @@ static bool CanPropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
       CommonPreds.insert(*PI);
 
   // Shortcut, if there are no common predecessors, merging is always safe
-  if (CommonPreds.begin() == CommonPreds.end())
+  if (CommonPreds.empty())
     return true;
   
   // Look at all the phi nodes in Succ, to see if they present a conflict when