Handle returning complex types that get coerced. Fixes PR3131

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60058 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
index 1fc4143..220586d 100644
--- a/lib/CodeGen/CGCall.cpp
+++ b/lib/CodeGen/CGCall.cpp
@@ -868,7 +868,10 @@
       llvm::PointerType::getUnqual(RetAI.getCoerceToType());
     llvm::Value *V = CreateTempAlloca(ConvertType(RetTy), "tmp");
     Builder.CreateStore(CI, Builder.CreateBitCast(V, CoerceToPTy));
-    return RValue::getAggregate(V);
+    if (RetTy->isAnyComplexType())
+      return RValue::getComplex(LoadComplexFromAddr(V, false));
+    else
+      return RValue::getAggregate(V);
   }
 
   case ABIArgInfo::ByVal: