diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index 9cc1d903f0f..c316f57268d 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -101,12 +101,15 @@ public: return Insert(ReturnInst::Create(V)); } - ReturnInst *CreateRet(Value * const* retVals, unsigned N) { + /// CreateAggregateRet - Create a sequence of N insertvalue instructions, + /// with one Value from the retVals array each, that build a aggregate + /// return value one value at a time, and a ret instruction to return + /// the resulting aggregate value. This is a convenience function for + /// code that uses aggregate return values as a vehicle for having + /// multiple return values. + /// + ReturnInst *CreateAggregateRet(Value * const* retVals, unsigned N) { const Type *RetType = BB->getParent()->getReturnType(); - if (N == 0 && RetType == Type::VoidTy) - return CreateRetVoid(); - if (N == 1 && retVals[0]->getType() == RetType) - return Insert(ReturnInst::Create(retVals[0])); Value *V = UndefValue::get(RetType); for (unsigned i = 0; i != N; ++i) V = CreateInsertValue(V, retVals[i], i, "mrv");