Enable first-class aggregates support.

Remove the GetResultInst instruction. It is still accepted in LLVM assembly
and bitcode, where it is now auto-upgraded to ExtractValueInst. Also, remove
support for return instructions with multiple values. These are auto-upgraded
to use InsertValueInst instructions.

The IRBuilder still accepts multiple-value returns, and auto-upgrades them
to InsertValueInst instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53941 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
index c024d32..ba58fbd 100644
--- a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
+++ b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
@@ -110,32 +110,13 @@
   //
   BasicBlock *NewRetBlock = BasicBlock::Create("UnifiedReturnBlock", &F);
 
-  SmallVector<Value *, 4> Phis;
-  unsigned NumRetVals = ReturningBlocks[0]->getTerminator()->getNumOperands();
-  if (NumRetVals == 0)
+  PHINode *PN = 0;
+  if (F.getReturnType() == Type::VoidTy) {
     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 {
+  } else {
     // If the function doesn't return void... add a PHI node to the block...
-    PHINode *PN = PHINode::Create(F.getReturnType(), "UnifiedRetVal");
+    PN = PHINode::Create(F.getReturnType(), "UnifiedRetVal");
     NewRetBlock->getInstList().push_back(PN);
-    Phis.push_back(PN);
     ReturnInst::Create(PN, NewRetBlock);
   }
 
@@ -148,11 +129,8 @@
 
     // Add an incoming element to the PHI node for every return instruction that
     // is merging into this new block...
-    if (!Phis.empty()) {
-      for (unsigned i = 0; i < NumRetVals; ++i) 
-        cast<PHINode>(Phis[i])->addIncoming(BB->getTerminator()->getOperand(i), 
-                                            BB);
-    }
+    if (PN)
+      PN->addIncoming(BB->getTerminator()->getOperand(0), BB);
 
     BB->getInstList().pop_back();  // Remove the return insn
     BranchInst::Create(NewRetBlock, BB);