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

John McCall rjmccall at apple.com
Mon May 6 00:05:30 PDT 2013

On May 4, 2013, at 9:29 PM, 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?

Enabling a new and not-necessarily-deeply-tested feature/optimization is
actually specifically the sort of thing we try *not* to do right before a
release branch. :)


More information about the cfe-commits mailing list