From a0fb00f9837bd0d2e5948f16f6a6b82a7a628f51 Mon Sep 17 00:00:00 2001
From: dim <dim@FreeBSD.org>
Date: Sat, 26 Feb 2011 22:09:03 +0000
Subject: Vendor import of clang trunk r126547:
 http://llvm.org/svn/llvm-project/cfe/trunk@126547

---
 lib/CodeGen/CGObjCMac.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

(limited to 'lib/CodeGen/CGObjCMac.cpp')

diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 7c679b9..8dbd85f 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -46,6 +46,15 @@ using namespace CodeGen;
 // don't belong in CGObjCRuntime either so we will live with it for
 // now.
 
+static void EmitNullReturnInitialization(CodeGenFunction &CGF,
+                                         ReturnValueSlot &returnSlot,
+                                         QualType resultType) {
+  // Force the return slot to exist.
+  if (!returnSlot.getValue())
+    returnSlot = ReturnValueSlot(CGF.CreateMemTemp(resultType), false);
+  CGF.EmitNullInitialization(returnSlot.getValue(), resultType);
+}
+
 static uint64_t LookupFieldBitOffset(CodeGen::CodeGenModule &CGM,
                                      const ObjCInterfaceDecl *OID,
                                      const ObjCImplementationDecl *ID,
@@ -1639,6 +1648,7 @@ CGObjCCommonMac::EmitLegacyMessageSend(CodeGen::CodeGenFunction &CGF,
 
   llvm::Constant *Fn = NULL;
   if (CGM.ReturnTypeUsesSRet(FnInfo)) {
+    EmitNullReturnInitialization(CGF, Return, ResultType);
     Fn = (ObjCABI == 2) ?  ObjCTypes.getSendStretFn2(IsSuper)
       : ObjCTypes.getSendStretFn(IsSuper);
   } else if (CGM.ReturnTypeUsesFPRet(ResultType)) {
@@ -5629,6 +5639,7 @@ CodeGen::RValue CGObjCNonFragileABIMac::EmitMessageSend(
   llvm::Constant *Fn = 0;
   std::string Name("\01l_");
   if (CGM.ReturnTypeUsesSRet(FnInfo)) {
+    EmitNullReturnInitialization(CGF, Return, ResultType);
     if (IsSuper) {
       Fn = ObjCTypes.getMessageSendSuper2StretFixupFn();
       Name += "objc_msgSendSuper2_stret_fixup";
-- 
cgit v1.1