[PATCH] [WinX86_64 ABI] Handle C99 _Complex as a struct

Michael Kuperstein michael.m.kuperstein at intel.com
Tue Feb 24 01:38:13 PST 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D7825

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGen/x86_64-arguments-win32.c

Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -3041,7 +3041,7 @@
       return ABIArgInfo::getDirect();
   }
 
-  if (RT || Ty->isMemberPointerType()) {
+  if (RT || Ty->isAnyComplexType() || Ty->isMemberPointerType()) {
     // MS x64 ABI requirement: "Any argument that doesn't fit in 8 bytes, or is
     // not 1, 2, 4, or 8 bytes, must be passed by reference."
     if (Width > 64 || !llvm::isPowerOf2_64(Width))
Index: cfe/trunk/test/CodeGen/x86_64-arguments-win32.c
===================================================================
--- cfe/trunk/test/CodeGen/x86_64-arguments-win32.c
+++ cfe/trunk/test/CodeGen/x86_64-arguments-win32.c
@@ -14,3 +14,18 @@
 
 // CHECK-LABEL: define void @f4(i16 %a)
 void f4(unsigned short a) {}
+
+// For ABI compatibility with ICC, _Complex should be passed/returned
+// as if it were a struct with two elements.
+
+// CHECK-LABEL: define void @f5(i64 %a.coerce)
+void f5(_Complex float a) {}
+
+// CHECK-LABEL: define void @f6({ double, double }* %a)
+void f6(_Complex double a) {}
+
+// CHECK-LABEL: define i64 @f7()
+_Complex float f7() { return 1.0; }
+
+// CHECK-LABEL: define void @f8({ double, double }* noalias sret %agg.result)
+_Complex double f8() { return 1.0; }

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7825.20574.patch
Type: text/x-patch
Size: 1368 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150224/cf9ba8ce/attachment.bin>


More information about the cfe-commits mailing list