Use SmallVector while constructing ReturnInst.
authorDevang Patel <dpatel@apple.com>
Tue, 26 Feb 2008 19:38:17 +0000 (19:38 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 26 Feb 2008 19:38:17 +0000 (19:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47619 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Instructions.h
lib/Bitcode/Reader/BitcodeReader.cpp
lib/VMCore/Instructions.cpp

index 316d6b5a091ceb89e90c6b1d108f6dfbbd86a581..2b7241e725366c8a4103e262c8f338a52eac68b1 100644 (file)
@@ -1400,6 +1400,9 @@ public:
   ReturnInst(const std::vector<Value *> &retVals);
   ReturnInst(const std::vector<Value *> &retVals, Instruction *InsertBefore);
   ReturnInst(const std::vector<Value *> &retVals, BasicBlock *InsertAtEnd);
+  ReturnInst(Value * const* retVals, unsigned N);
+  ReturnInst(Value * const* retVals, unsigned N, Instruction *InsertBefore);
+  ReturnInst(Value * const* retVals, unsigned N, BasicBlock *InsertAtEnd);
   explicit ReturnInst(BasicBlock *InsertAtEnd);
   virtual ~ReturnInst();
 
index 487a135509c40ada0322250721d8ce57212a64ec..61e0ab9898909bcd0b4448ff6993a7b4cb16eb79 100644 (file)
@@ -21,6 +21,7 @@
 #include "llvm/ParamAttrsList.h"
 #include "llvm/AutoUpgrade.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 using namespace llvm;
@@ -1344,7 +1345,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
           break;
         } else {
           unsigned OpNum = 0;
-          std::vector<Value *> Vs;
+          SmallVector<Value *,4> Vs;
           do {
             Value *Op = NULL;
             if (getValueTypePair(Record, OpNum, NextValueNo, Op))
@@ -1352,7 +1353,8 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
             Vs.push_back(Op);
           } while(OpNum != Record.size());
 
-          I = new ReturnInst(Vs);
+          // SmallVector Vs has at least one element.
+          I = new ReturnInst(&Vs[0], Vs.size());
           break;
         }
       }
index ffd93dbc6227d9146d41c8b6252264031eae5b7b..012aad189eb0e16d2e0d9662555379dd143fd0ee 100644 (file)
@@ -618,6 +618,24 @@ ReturnInst::ReturnInst(const std::vector<Value *> &retVals)
     init(&retVals[0], retVals.size());
 }
 
+ReturnInst::ReturnInst(Value * const* retVals, unsigned N,
+                       Instruction *InsertBefore)
+  : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, N, InsertBefore) {
+  if (N != 0)
+    init(retVals, N);
+}
+ReturnInst::ReturnInst(Value * const* retVals, unsigned N,
+                       BasicBlock *InsertAtEnd)
+  : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, N, InsertAtEnd) {
+  if (N != 0)
+    init(retVals, N);
+}
+ReturnInst::ReturnInst(Value * const* retVals, unsigned N)
+  : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, N) {
+  if (N != 0)
+    init(retVals, N);
+}
+
 void ReturnInst::init(Value * const* retVals, unsigned N) {
 
   assert (N > 0 && "Invalid operands numbers in ReturnInst init");