Add comment.
[oota-llvm.git] / lib / VMCore / Instructions.cpp
index 163601a6c13304d6c11cb44659f65479cbe93caf..c0b3413da33782870832f11d011181ba3ab69485 100644 (file)
@@ -586,49 +586,42 @@ ReturnInst::ReturnInst(const ReturnInst &RI)
 
 ReturnInst::ReturnInst(Value *retVal, Instruction *InsertBefore)
   : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertBefore) {
-  init(retVal);
+  if (retVal)
+    init(&retVal, 1);
 }
 ReturnInst::ReturnInst(Value *retVal, BasicBlock *InsertAtEnd)
   : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertAtEnd) {
-  init(retVal);
+  if (retVal)
+    init(&retVal, 1);
 }
 ReturnInst::ReturnInst(BasicBlock *InsertAtEnd)
   : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertAtEnd) {
 }
 
-ReturnInst::ReturnInst(const std::vector<Value *> &retVals, 
+ReturnInst::ReturnInst(Value * const* retVals, unsigned N,
                        Instruction *InsertBefore)
-  : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, retVals.size(), 
-                   InsertBefore) {
-  init(retVals);
+  : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, N, InsertBefore) {
+  if (N != 0)
+    init(retVals, N);
 }
-ReturnInst::ReturnInst(const std::vector<Value *> &retVals, 
+ReturnInst::ReturnInst(Value * const* retVals, unsigned N,
                        BasicBlock *InsertAtEnd)
-  : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, retVals.size(), 
-                   InsertAtEnd) {
-  init(retVals);
+  : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, N, InsertAtEnd) {
+  if (N != 0)
+    init(retVals, N);
 }
-ReturnInst::ReturnInst(const std::vector<Value *> &retVals)
-  : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, retVals.size()) {
-  init(retVals);
+ReturnInst::ReturnInst(Value * const* retVals, unsigned N)
+  : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, N) {
+  if (N != 0)
+    init(retVals, N);
 }
 
-void ReturnInst::init(Value *retVal) {
-  if (retVal && retVal->getType() != Type::VoidTy) {
-    assert(!isa<BasicBlock>(retVal) &&
-           "Cannot return basic block.  Probably using the incorrect ctor");
-    NumOperands = 1;
-    RetVal.init(retVal, this);
-  }
-}
-
-void ReturnInst::init(const std::vector<Value *> &retVals) {
-  if (retVals.empty())
-    return;
+void ReturnInst::init(Value * const* retVals, unsigned N) {
+  assert (N > 0 && "Invalid operands numbers in ReturnInst init");
 
-  NumOperands = retVals.size();
+  NumOperands = N;
   if (NumOperands == 1) {
-    Value *V = retVals[0];
+    Value *V = *retVals;
     if (V->getType() == Type::VoidTy)
       return;
     RetVal.init(V, this);
@@ -636,26 +629,14 @@ void ReturnInst::init(const std::vector<Value *> &retVals) {
   }
 
   Use *OL = OperandList = new Use[NumOperands];
-  RetVal.init(retVals[0], this);
   for (unsigned i = 0; i < NumOperands; ++i) {
-    Value *V = retVals[i];
+    Value *V = *retVals++;
     assert(!isa<BasicBlock>(V) &&
            "Cannot return basic block.  Probably using the incorrect ctor");
     OL[i].init(V, this);
   }
 }
 
-Value *ReturnInst::getReturnValue(unsigned n) const {
-  if (getNumOperands() == 0)
-    return 0;
-
-  assert (n < getNumOperands() && "getReturnValue out of range!");
-  if (getNumOperands() == 1)
-    return RetVal;
-  else 
-    return OperandList[n];
-}
-
 unsigned ReturnInst::getNumSuccessorsV() const {
   return getNumSuccessors();
 }