[llvm-commits] [llvm-gcc-4.2] r91964 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Bob Wilson bob.wilson at apple.com
Tue Dec 22 17:03:43 PST 2009


Author: bwilson
Date: Tue Dec 22 19:03:43 2009
New Revision: 91964

URL: http://llvm.org/viewvc/llvm-project?rev=91964&view=rev
Log:
When a large aggregate is passed as an operand to an inline asm with a register
constraint, report an error instead of treating it as an "indirect" operand.
Codegen only supports indirect operands with memory constraints, and it will
just assert or crash otherwise.

For 128-bit aggregate asm operands, pass them as integers, but only if they
must be in registers.  This is important for compatibility with gcc for
inline asm using types from <arm_neon.h>.  The llvm versions of those types
have the vector values wrapped in structs.  Radar 7483577.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=91964&r1=91963&r2=91964&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Dec 22 19:03:43 2009
@@ -4450,17 +4450,19 @@
         LValue LV = EmitLV(Val);
         assert(!LV.isBitfield() && "Inline asm can't have bitfield operand");
 
-        // Structs and unions are permitted here, as long as they're the
-        // same size as a register.
+        // Small structs and unions can be treated as integers.
         uint64_t TySize = TD.getTypeSizeInBits(LLVMTy);
         if (TySize == 1 || TySize == 8 || TySize == 16 ||
-            TySize == 32 || TySize == 64) {
+            TySize == 32 || TySize == 64 || (TySize == 128 && !AllowsMem)) {
           LLVMTy = IntegerType::get(Context, TySize);
           Op = Builder.CreateLoad(BitCastToType(LV.Ptr,
-                                 LLVMTy->getPointerTo()));
+                                                LLVMTy->getPointerTo()));
         } else {
-          // Otherwise, emit our value as a lvalue and let the codegen deal with
-          // it.
+          // Codegen only supports indirect operands with mem constraints.
+          if (!AllowsMem)
+            error("%Haggregate does not match inline asm register constraint",
+                  &EXPR_LOCATION(exp));
+          // Otherwise, emit our value as a lvalue.
           isIndirect = true;
           Op = LV.Ptr;
         }





More information about the llvm-commits mailing list