pete added a comment.

Hi John

Sorry, getting back to this after way too long!

In http://reviews.llvm.org/D14737#294218, @rjmccall wrote:

> In http://reviews.llvm.org/D14737#293967, @pete wrote:
>
> > Added a couple of tests for retain returning types other than id.  
> > Returning a pointer should still be converted to a call, while returning a 
> > non-pointer such as float will get a message instead.
> >
> > I walked through the code in the debugger to check on the return cast.  
> > Turns out it is handled at the very end of emitARCValueOperation as follows:
> >
> >  
> >   // Cast the result back to the original type.
> >   return CGF.Builder.CreateBitCast(call, origType);
>
>
> Right, that'll cast back to the original type.  That will be the type of the 
> receiver of the message, which is not necessarily the type of the result of 
> the message.


I stepped through this one in the debugger to make sure I had it right.

So the reason the bit cast ends up not being needed is because we restricted 
this optimization to cases where the result type "isObjCObjectPointerType()" 
which conveniently ends up begin i8* and is exactly the same type as the 
message receiver.  I guess if either the receiver type or the result type 
wasn't represented as i8* then the IRBuilder would have crashed.

If we permitted converting say messaging (int*)retain to a call to objc_retain 
then the bit cast would be needed.  Would you like me to permit this change on 
functions returning anything other than isObjCObjectPointerType(), eg, change 
that to "isAnyPointerType()"?

Cheers,
Pete


http://reviews.llvm.org/D14737



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to