<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On May 22, 2010, at 9:13 AM, Fariborz Jahanian wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>On May 21, 2010, at 6:48 PM, John McCall wrote:<br><br><blockquote type="cite">Author: rjmccall<br></blockquote><blockquote type="cite">Date: Fri May 21 20:48:05 2010<br></blockquote><blockquote type="cite">New Revision: 104422<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=104422&view=rev">http://llvm.org/viewvc/llvm-project?rev=104422&view=rev</a><br></blockquote><blockquote type="cite">Log:<br></blockquote><blockquote type="cite">Push a return-value slot throughout ObjC message-send codegen.  Will  <br></blockquote><blockquote type="cite">be<br></blockquote><blockquote type="cite">critical for ObjC++ correctness;  hard to test independently of  <br></blockquote><blockquote type="cite">various<br></blockquote><blockquote type="cite">required Sema changes, though.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Modified:<br></blockquote><blockquote type="cite">   cfe/trunk/lib/CodeGen/CGExprAgg.cpp<br></blockquote><blockquote type="cite">   cfe/trunk/lib/CodeGen/CGObjC.cpp<br></blockquote><blockquote type="cite">   cfe/trunk/lib/CodeGen/CGObjCGNU.cpp<br></blockquote><blockquote type="cite">   cfe/trunk/lib/CodeGen/CGObjCMac.cpp<br></blockquote><blockquote type="cite">   cfe/trunk/lib/CodeGen/CGObjCRuntime.h<br></blockquote><blockquote type="cite">   cfe/trunk/lib/CodeGen/CodeGenFunction.h<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp<br></blockquote><blockquote type="cite">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=104422&r1=104421&r2=104422&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=104422&r1=104421&r2=104422&view=diff</a><br></blockquote><blockquote type="cite">= <br></blockquote><blockquote type="cite">= <br></blockquote><blockquote type="cite">= <br></blockquote><blockquote type="cite">= <br></blockquote><blockquote type="cite">= <br></blockquote><blockquote type="cite">= <br></blockquote><blockquote type="cite">= <br></blockquote><blockquote type="cite">= <br></blockquote><blockquote type="cite">======================================================================<br></blockquote><blockquote type="cite">--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)<br></blockquote><blockquote type="cite">+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Fri May 21 20:48:05 2010<br></blockquote><blockquote type="cite">@@ -37,6 +37,10 @@<br></blockquote><blockquote type="cite">  bool IgnoreResult;<br></blockquote><blockquote type="cite">  bool IsInitializer;<br></blockquote><blockquote type="cite">  bool RequiresGCollection;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+  ReturnValueSlot getReturnValueSlot() const {<br></blockquote><blockquote type="cite">+    return ReturnValueSlot(DestPtr, VolatileDest);<br></blockquote><blockquote type="cite">+  }<br></blockquote><blockquote type="cite">public:<br></blockquote><blockquote type="cite">  AggExprEmitter(CodeGenFunction &cgf, llvm::Value *destPtr, bool v,<br></blockquote><blockquote type="cite">                 bool ignore, bool isinit, bool requiresGCollection)<br></blockquote><blockquote type="cite">@@ -299,7 +303,7 @@<br></blockquote><blockquote type="cite">  // If the struct doesn't require GC, we can just pass the  <br></blockquote><blockquote type="cite">destination<br></blockquote><blockquote type="cite">  // directly to EmitCall.<br></blockquote><blockquote type="cite">  if (!RequiresGCollection) {<br></blockquote><blockquote type="cite">-    CGF.EmitCallExpr(E, ReturnValueSlot(DestPtr, VolatileDest));<br></blockquote><blockquote type="cite">+    CGF.EmitCallExpr(E, getReturnValueSlot());<br></blockquote><blockquote type="cite">    return;<br></blockquote><blockquote type="cite">  }<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">@@ -308,19 +312,16 @@<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">void AggExprEmitter::VisitObjCMessageExpr(ObjCMessageExpr *E) {<br></blockquote><blockquote type="cite">-  RValue RV = CGF.EmitObjCMessageExpr(E);<br></blockquote><blockquote type="cite">-  EmitFinalDestCopy(E, RV);<br></blockquote><blockquote type="cite">+  CGF.EmitObjCMessageExpr(E, getReturnValueSlot());<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">void AggExprEmitter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr  <br></blockquote><blockquote type="cite">*E) {<br></blockquote><blockquote type="cite">-  RValue RV = CGF.EmitObjCPropertyGet(E);<br></blockquote><blockquote type="cite">-  EmitFinalDestCopy(E, RV);<br></blockquote><blockquote type="cite">+  CGF.EmitObjCPropertyGet(E, getReturnValueSlot());<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">void AggExprEmitter::VisitObjCImplicitSetterGetterRefExpr(<br></blockquote><blockquote type="cite">                                   ObjCImplicitSetterGetterRefExpr  <br></blockquote><blockquote type="cite">*E) {<br></blockquote><blockquote type="cite">-  RValue RV = CGF.EmitObjCPropertyGet(E);<br></blockquote><blockquote type="cite">-  EmitFinalDestCopy(E, RV);<br></blockquote><blockquote type="cite">+  CGF.EmitObjCPropertyGet(E, getReturnValueSlot());<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite"><br></blockquote><br><br>Hi John,<br><br>Wouldn't removing call to EmitFinalDestCopy change things in this  <br>patch? This routine deals with GC API, as well as copying result to  <br>DestPtr.<br></div></blockquote><div><br></div><div>The problem with EmitFinalDestCopy is that it attempts to memcpy non-POD class types in C++, which is wrong. So, we're moving to a system where we avoid the memcpy's altogether by using the return slot of the function. That's good for performance and for correctness. Why does the GC need to know about this?</div><br><blockquote type="cite"><div>Our clang test has minimal coverage of API issues.<font class="Apple-style-span" color="#000000"><font class="Apple-style-span" color="#144FAE"><br></font></font></div></blockquote><br></div><div>:(</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>- Doug</div></body></html>