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

John McCall rjmccall at apple.com
Thu May 2 11:28:21 PDT 2013


On May 1, 2013, at 7:56 AM, Stephen Lin <swlin at post.harvard.edu> wrote:
> This patch converts the implementation of 'this'-returning
> constructors and destructors (in ARM and MS C++ ABIs) to use the new
> 'returned' attribute.
> 
> It does so by adding a new flag to FunctionType::ExtInfo and other
> associated classes which indicates that a function returns its first
> argument; only a single bit is used currently since the only use cases
> for this attribute are for the first parameter, but the API is
> designed to theoretically allow the the attribute on any parameter if
> needed later by increasing the number of reserved flag bits for the
> field.

This optimization is definitely not worth the complexity cost of raising it into
the formal type system.  Just find a way to add the new function attribute to
the LLVM function declaration when creating a constructor or destructor.

If we added a user-level attribute, that's how we'd handle it as well.

LLVM has existing built-in knowledge of specific functions like memcpy;
it can be responsible for adding this annotation as appropriate to them
(when allowed).

John.



More information about the cfe-commits mailing list