Fix SmallVector's size calculation so that a size of 0 is
authorDan Gohman <gohman@apple.com>
Fri, 22 Aug 2008 16:07:55 +0000 (16:07 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 22 Aug 2008 16:07:55 +0000 (16:07 +0000)
handled correctly, and change a few SmallVector uses to use
size 0 to more clearly reflect their intent.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55181 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/SmallVector.h
lib/CodeGen/BranchFolding.cpp
lib/CodeGen/IfConversion.cpp

index 05952a4490e4a095fd9919cef4e148b666656b0e..fdecb6c44812dc25266a68548e59b29d979eac7c 100644 (file)
@@ -477,7 +477,7 @@ class SmallVector : public SmallVectorImpl<T> {
     // NumInlineEltsElts - The number of elements actually in this array.  There
     // is already one in the parent class, and we have to round up to avoid
     // having a zero-element array.
-    NumInlineEltsElts = (MinUs - 1) > 0 ? (MinUs - 1) : 1,
+    NumInlineEltsElts = MinUs > 1 ? (MinUs - 1) : 1,
     
     // NumTsAvailable - The number of T's we actually have space for, which may
     // be more than N due to rounding.
index c97f176d74b1c5bac6e5b82b83ad33d39728e2b7..2ccfd191a093eba3b34abe56b3c2c3e8f8ca16ae 100644 (file)
@@ -364,7 +364,7 @@ void BranchFolder::ReplaceTailWithBranchTo(MachineBasicBlock::iterator OldInst,
 
   // If OldBB isn't immediately before OldBB, insert a branch to it.
   if (++MachineFunction::iterator(OldBB) != MachineFunction::iterator(NewDest))
-    TII->InsertBranch(*OldBB, NewDest, 0, SmallVector<MachineOperand, 1>());
+    TII->InsertBranch(*OldBB, NewDest, 0, SmallVector<MachineOperand, 0>());
   OldBB->addSuccessor(NewDest);
   ++NumTailMerge;
 }
@@ -444,7 +444,7 @@ static void FixTail(MachineBasicBlock* CurMBB, MachineBasicBlock *SuccBB,
       }
     }
   }
-  TII->InsertBranch(*CurMBB, SuccBB, NULL, SmallVector<MachineOperand, 1>());
+  TII->InsertBranch(*CurMBB, SuccBB, NULL, SmallVector<MachineOperand, 0>());
 }
 
 static bool MergeCompare(const std::pair<unsigned,MachineBasicBlock*> &p,
index d98b0ceb2dda296474579ca9a62fff65c754ca2a..079b701648020b69b4c3da673dc6714fe9c46648 100644 (file)
@@ -815,7 +815,7 @@ void IfConverter::InvalidatePreds(MachineBasicBlock *BB) {
 ///
 static void InsertUncondBranch(MachineBasicBlock *BB, MachineBasicBlock *ToBB,
                                const TargetInstrInfo *TII) {
-  SmallVector<MachineOperand, 1> NoCond;
+  SmallVector<MachineOperand, 0> NoCond;
   TII->InsertBranch(*BB, ToBB, NULL, NoCond);
 }