- SmallVector<Value *, 4> Phis;
- unsigned NumRetVals = ReturningBlocks[0]->getTerminator()->getNumOperands();
- if (NumRetVals == 0)
- ReturnInst::Create(NULL, NewRetBlock);
- else if (const StructType *STy = dyn_cast<StructType>(F.getReturnType())) {
- Instruction *InsertPt = NULL;
- if (NumRetVals == 0)
- InsertPt = NewRetBlock->getFirstNonPHI();
- PHINode *PN = NULL;
- for (unsigned i = 0; i < NumRetVals; ++i) {
- if (InsertPt)
- PN = PHINode::Create(STy->getElementType(i), "UnifiedRetVal."
- + utostr(i), InsertPt);
- else
- PN = PHINode::Create(STy->getElementType(i), "UnifiedRetVal."
- + utostr(i), NewRetBlock);
- Phis.push_back(PN);
- InsertPt = PN;
- }
- ReturnInst::Create(&Phis[0], NumRetVals, NewRetBlock);
- }
- else {
+ PHINode *PN = nullptr;
+ if (F.getReturnType()->isVoidTy()) {
+ ReturnInst::Create(F.getContext(), nullptr, NewRetBlock);
+ } else {