[PATCH] Have 'this'-returning constructors and destructors to take advantage of the new backend 'returned' attribute

Stephen Lin swlin at post.harvard.edu
Sat May 4 22:34:17 PDT 2013


On Sun, May 5, 2013 at 12:29 AM, Stephen Lin <swlin at post.harvard.edu> wrote:
>> OK, sorry for the noise: it turns out the last patch I sent it doing
>> the right thing, but largely be accident: it's not attaching
>> 'returned' to the call site and only at the declaration/definition, so
>> only direct calls end up using the 'returned' attribute, which is what
>> we want.
>>
>> But this is actually because EmitCall treats the call as
>> void-returning even when it returns 'this', because the return value
>> is gets is based on semantic ReturnValueSlot rather than from the
>> ABI-provided constructor signature, so ConstructAttributeList is
>> called with a 'this'-return when constructing a declaration/definition
>> but a 'void' return when constructing a call site. I'm surprised this
>> doesn't trigger any asserts, actually...
>>
>> Anyway, since this is not behavior that should be relied upon (and
>> maybe should be fixed at some point, too), I fixed it so that
>> 'returned' is applied by SetFunctionAttributes(), which is only
>> applied to declarations/definitions rather than call sites and takes a
>> GlobalDecl already. So this is probably the minimal impact method of
>> implementing this.
>>
>> Thanks for bringing up the thunk issue; would not have realized what
>> was going on otherwise. Please let me know if you have any more
>> suggestions or comments.
>>
>> -Stephen
>
> Hi John,
>
> No worries if not, but do you think you'll be able to review this in
> time for the 3.3 branching on Monday?
>
> If there's anything else I should refine about the implementation
> please let me know.
>
> -Stephen

I make a few clean-up fixes to the patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: this-return1.patch
Type: application/octet-stream
Size: 16483 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130505/a3704baf/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: this-return2.patch
Type: application/octet-stream
Size: 27150 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130505/a3704baf/attachment-0001.obj>


More information about the cfe-commits mailing list