[llvm-branch-commits] [llvm-gcc-branch] r90987 - /llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-convert.cpp

Bill Wendling isanbard at gmail.com
Wed Dec 9 13:48:59 PST 2009


Author: void
Date: Wed Dec  9 15:48:59 2009
New Revision: 90987

URL: http://llvm.org/viewvc/llvm-project?rev=90987&view=rev
Log:
Reapply:

$ svn merge -c 90914 https://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk
--- Merging r90914 into '.':
U    gcc/llvm-convert.cpp


Modified:
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-convert.cpp?rev=90987&r1=90986&r2=90987&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-convert.cpp Wed Dec  9 15:48:59 2009
@@ -2776,8 +2776,26 @@
     return 0;
 
   if (Client.isAggrReturn()) {
-    Value *Dest = BitCastToType(DestLoc->Ptr, Call->getType()->getPointerTo());
-    LLVM_EXTRACT_MULTIPLE_RETURN_VALUE(Call,Dest,DestLoc->Volatile,Builder);
+    if (TD.getTypeAllocSize(Call->getType()) <= TD.getTypeAllocSize(DestLoc->Ptr->getType())) {
+      Value *Dest = BitCastToType(DestLoc->Ptr, Call->getType()->getPointerTo());
+      LLVM_EXTRACT_MULTIPLE_RETURN_VALUE(Call,Dest,DestLoc->Volatile,Builder);
+    } else {
+      // The call will return an aggregate value in registers, but
+      // those registers are bigger than DestLoc.  Allocate a
+      // temporary to match the registers, store the registers there,
+      // cast the temporary into the correct (smaller) type, and using
+      // the correct type, copy the value into DestLoc.  Assume the
+      // optimizer will delete the temporary and clean this up.
+      AllocaInst *biggerTmp = CreateTemporary(Call->getType());
+      LLVM_EXTRACT_MULTIPLE_RETURN_VALUE(Call,biggerTmp,/*Volatile=*/false,
+					 Builder);
+      EmitAggregateCopy(*DestLoc,
+			MemRef(BitCastToType(biggerTmp,Call->getType()->
+					     getPointerTo()),
+			       DestLoc->getAlignment(),
+			       DestLoc->Volatile),
+			TREE_TYPE(exp));
+    }
     return 0;
   }
 





More information about the llvm-branch-commits mailing list