rjmccall added a comment.

In http://reviews.llvm.org/D14737#373532, @pete wrote:

> 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()"?


The IR type for an AST type satisfying isObjCObjectPointerType() isn't always 
i8*; in particular, that's not true when the receiver has a concrete class type.

A test case here would be something like:

@interface Foo

- (id) retain;

@end

...

id test(Foo *foo) {

  return [foo retain];

}

Here the receiver type will be something like %struct.Foo* and the expected 
return type will be i8*.


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