On May 2, 2013, at 1:59 PM, Stephen Lin <[email protected]> wrote: > On Thu, May 2, 2013 at 2:28 PM, John McCall <[email protected]> wrote: >> On May 1, 2013, at 7:56 AM, Stephen Lin <[email protected]> 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. > > Thanks for the reply and feedback. To clarify, so you mean to avoid > putting it in FunctionType::ExtInfo? I was hesistant to add it there > for the complexity cost you mentioned but couldn't figure out a better > place to put it: the information seems to have to get to > CodeGenModule::ConstructAttributeList somehow, or is there another > convenient place to add attributes to a parameter of a function > declaration?
CodeGenModule::ConstructAttributeList gets the Decl; just have it check for a ctor or dtor and ask the CXXABI whether that Decl promises to return 'this'. John. _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
