[llvm-commits] [125990] Switch approaches used to handle union destinations.

clattner at apple.com clattner at apple.com
Wed Apr 11 16:44:57 PDT 2007


Revision: 125990
Author:   clattner
Date:     2007-04-11 16:44:56 -0700 (Wed, 11 Apr 2007)

Log Message:
-----------
Switch approaches used to handle union destinations.  This approach 
correctly handles multi-element struct destinations as well, and 
doesn't require a codegen change.

Modified Paths:
--------------
    apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-convert.cpp	2007-04-11 22:35:32 UTC (rev 125989)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp	2007-04-11 23:44:56 UTC (rev 125990)
@@ -3603,9 +3603,16 @@
     LValue Dest = EmitLV(Operand);
     const Type *DestValTy =
       cast<PointerType>(Dest.Ptr->getType())->getElementType();
+    if (!DestValTy->isFirstClassType()) {
+      // If this is a pointer to a structure or a union, convert this to be a
+      // pointer to a same-sized integer.  GCC allows destinations of structs
+      // and unions if they are the same size as a register.
+      DestValTy = IntegerType::get(TD.getTypeSizeInBits(DestValTy));
+      Dest.Ptr = new BitCastInst(Dest.Ptr, PointerType::get(DestValTy), "tmp",
+                                 CurBB);
+    }
     assert(!Dest.isBitfield() && "Cannot assign into a bitfield!");
-    if (ConstraintStr.empty() && !AllowsMem &&
-        DestValTy->isFirstClassType()) {  // Reg dest and no output yet?
+    if (ConstraintStr.empty() && !AllowsMem) {  // Reg dest and no output yet?
       assert(StoreCallResultAddr == 0 && "Already have a result val?");
       StoreCallResultAddr = Dest.Ptr;
       ConstraintStr += ",";





More information about the llvm-commits mailing list