[cfe-commits] r144612 - in /cfe/trunk: lib/CodeGen/CGCall.cpp test/CodeGen/x86_32-arguments-darwin.c

Eli Friedman eli.friedman at gmail.com
Mon Nov 14 18:46:04 PST 2011


Author: efriedma
Date: Mon Nov 14 20:46:03 2011
New Revision: 144612

URL: http://llvm.org/viewvc/llvm-project?rev=144612&view=rev
Log:
Fix crash in calling convention code expanding an struct with a complex member.


Modified:
    cfe/trunk/lib/CodeGen/CGCall.cpp
    cfe/trunk/test/CodeGen/x86_32-arguments-darwin.c

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=144612&r1=144611&r2=144612&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Nov 14 20:46:03 2011
@@ -1513,7 +1513,10 @@
       llvm::Value *EltAddr = Builder.CreateConstGEP2_32(Addr, 0, Elt);
       LValue LV = MakeAddrLValue(EltAddr, EltTy);
       RValue EltRV;
-      if (CodeGenFunction::hasAggregateLLVMType(EltTy))
+      if (EltTy->isAnyComplexType())
+        // FIXME: Volatile?
+        EltRV = RValue::getComplex(LoadComplexFromAddr(LV.getAddress(), false));
+      else if (CodeGenFunction::hasAggregateLLVMType(EltTy))
         EltRV = RValue::getAggregate(LV.getAddress());
       else
         EltRV = EmitLoadOfLValue(LV);
@@ -1531,13 +1534,16 @@
       // FIXME: What are the right qualifiers here?
       LValue LV = EmitLValueForField(Addr, FD, 0);
       RValue FldRV;
-      if (CodeGenFunction::hasAggregateLLVMType(FT))
+      if (FT->isAnyComplexType())
+        // FIXME: Volatile?
+        FldRV = RValue::getComplex(LoadComplexFromAddr(LV.getAddress(), false));
+      else if (CodeGenFunction::hasAggregateLLVMType(FT))
         FldRV = RValue::getAggregate(LV.getAddress());
       else
         FldRV = EmitLoadOfLValue(LV);
       ExpandTypeToArgs(FT, FldRV, Args, IRFuncTy);
     }
-  } else if (isa<ComplexType>(Ty)) {
+  } else if (Ty->isAnyComplexType()) {
     ComplexPairTy CV = RV.getComplexVal();
     Args.push_back(CV.first);
     Args.push_back(CV.second);

Modified: cfe/trunk/test/CodeGen/x86_32-arguments-darwin.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_32-arguments-darwin.c?rev=144612&r1=144611&r2=144612&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/x86_32-arguments-darwin.c (original)
+++ cfe/trunk/test/CodeGen/x86_32-arguments-darwin.c Mon Nov 14 20:46:03 2011
@@ -275,3 +275,8 @@
   f56_0(1, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
         a10, a11, a12, a13);
 }
+
+// CHECK: define void @f57(i32 %x.0, i32 %x.1)
+// CHECK: call void @f57(
+struct s57 { _Complex int x; };
+void f57(struct s57 x) {} void f57a(void) { f57((struct s57){1}); }





More information about the cfe-commits mailing list