[cfe-commits] r104215 - in /cfe/trunk: lib/CodeGen/CGVTables.cpp test/CodeGenCXX/thunks.cpp

Douglas Gregor dgregor at apple.com
Wed May 19 22:54:35 PDT 2010


Author: dgregor
Date: Thu May 20 00:54:35 2010
New Revision: 104215

URL: http://llvm.org/viewvc/llvm-project?rev=104215&view=rev
Log:
When creating a this-adjustment thunk where the return value is of C++
class type (that uses a return slot), pass the return slot to the
callee directly rather than allocating new storage and trying to copy
the object. This appears to have been the cause of the remaining two
Boost.Interprocess failures.

Modified:
    cfe/trunk/lib/CodeGen/CGVTables.cpp
    cfe/trunk/test/CodeGenCXX/thunks.cpp

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=104215&r1=104214&r2=104215&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Thu May 20 00:54:35 2010
@@ -2657,8 +2657,15 @@
     CGM.getTypes().getFunctionInfo(ResultType, CallArgs,
                                    FPT->getExtInfo());
   
+  // Determine whether we have a return value slot to use.
+  ReturnValueSlot Slot;
+  if (!ResultType->isVoidType() &&
+      FnInfo.getReturnInfo().getKind() == ABIArgInfo::Indirect &&
+      hasAggregateLLVMType(CurFnInfo->getReturnType()))
+    Slot = ReturnValueSlot(ReturnValue, ResultType.isVolatileQualified());
+  
   // Now emit our call.
-  RValue RV = EmitCall(FnInfo, Callee, ReturnValueSlot(), CallArgs, MD);
+  RValue RV = EmitCall(FnInfo, Callee, Slot, CallArgs, MD);
   
   if (!Thunk.Return.isEmpty()) {
     // Emit the return adjustment.
@@ -2701,7 +2708,7 @@
     RV = RValue::get(ReturnValue);
   }
 
-  if (!ResultType->isVoidType())
+  if (!ResultType->isVoidType() && Slot.isNull())
     EmitReturnOfRValue(RV, ResultType);
 
   FinishFunction();

Modified: cfe/trunk/test/CodeGenCXX/thunks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/thunks.cpp?rev=104215&r1=104214&r2=104215&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/thunks.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/thunks.cpp Thu May 20 00:54:35 2010
@@ -86,10 +86,6 @@
 
 }
 
-// This is from Test5:
-// CHECK: define linkonce_odr void @_ZTv0_n24_N5Test51B1fEv
-// CHECK: define internal void @_ZThn8_N12_GLOBAL__N_11C1fEv(
-
 // Check that the thunk gets internal linkage.
 namespace {
 
@@ -134,4 +130,49 @@
 }
 }
 
+namespace Test6 {
+  struct X {
+    X();
+    X(const X&);
+    X &operator=(const X&);
+    ~X();
+  };
+
+  struct P {
+    P();
+    P(const P&);
+    ~P();
+    X first;
+    X second;
+  };
+
+  P getP();
+
+  struct Base1 {
+    int i;
+
+    virtual X f() { return X(); }
+  };
+
+  struct Base2 {
+    float real;
+
+    virtual X f() { return X(); }
+  };
+
+  struct Thunks : Base1, Base2 {
+    long l;
+
+    virtual X f();
+  };
+
+  // CHECK: define void @_ZThn16_N5Test66Thunks1fEv
+  // CHECK-NOT: memcpy
+  // CHECK: {{call void @_ZN5Test66Thunks1fEv.*sret}}
+  // CHECK: ret void
+  X Thunks::f() { return X(); }
+}
 
+// This is from Test5:
+// CHECK: define linkonce_odr void @_ZTv0_n24_N5Test51B1fEv
+// CHECK: define internal void @_ZThn8_N12_GLOBAL__N_11C1fEv(





More information about the cfe-commits mailing list