[PATCH] CodeGen: Let arrays be inputs to inline asm

David Majnemer david.majnemer at gmail.com
Fri Jul 4 01:07:05 PDT 2014


Hi rsmith, rnk,

An array showing up in an inline assembly input is accepted in ICC and
GCC 4.8

This fixes PR20201.

http://reviews.llvm.org/D4382

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGen/asm.c
  test/CodeGen/x86-64-inline-asm.c

Index: lib/CodeGen/CGExpr.cpp
===================================================================
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -2781,7 +2781,6 @@
   switch (E->getCastKind()) {
   case CK_ToVoid:
   case CK_BitCast:
-  case CK_ArrayToPointerDecay:
   case CK_FunctionToPointerDecay:
   case CK_NullToMemberPointer:
   case CK_NullToPointer:
@@ -2836,6 +2835,7 @@
     return MakeAddrLValue(EmitDynamicCast(V, DCE), E->getType());
   }
 
+  case CK_ArrayToPointerDecay:
   case CK_ConstructorConversion:
   case CK_UserDefinedConversion:
   case CK_CPointerToObjCPointerCast:
Index: test/CodeGen/asm.c
===================================================================
--- test/CodeGen/asm.c
+++ test/CodeGen/asm.c
@@ -239,3 +239,12 @@
 // CHECK: call void asm sideeffect "/* $0 */", "i|r,~{dirflag},~{fpsr},~{flags}"(i32 1)
 }
 
+static unsigned t29_var[1];
+
+void t29(void) {
+  asm volatile("movl %%eax, %0"
+               :
+               : "m"(t29_var));
+  // CHECK: @t29
+  // CHECK: call void asm sideeffect "movl %eax, $0", "*m,~{dirflag},~{fpsr},~{flags}"([1 x i32]* @t29_var)
+}
Index: test/CodeGen/x86-64-inline-asm.c
===================================================================
--- test/CodeGen/x86-64-inline-asm.c
+++ test/CodeGen/x86-64-inline-asm.c
@@ -10,3 +10,8 @@
 // expected-error at -5 {{scale factor without index register is ignored}}
 #endif
 }
+
+static unsigned var[1] = {};
+void g(void) { asm volatile("movd %%xmm0, %0"
+                            :
+                            : "m"(var)); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4382.11077.patch
Type: text/x-patch
Size: 1559 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140704/feafdc3e/attachment.bin>


More information about the cfe-commits mailing list