[cfe-dev] "byval" when there is a non-trivial Destructor or Copy Constructor

Eli Friedman eli.friedman at gmail.com
Wed Nov 2 15:00:36 PDT 2011


On Wed, Nov 2, 2011 at 2:33 PM, Jan Voung <jvoung at google.com> wrote:
> re: passing c++ objects with copy constructors/destructors, there are
> multiple ABIs for doing this (e.g., the gcc way, msvc way). Is there a
> reason that the DefaultABIInfo's classifyArgumentType doesn't match either
> of the existing ABIs? It both makes a temp copy the gcc way, AND marks
> pointers as "byval". All of the other ABIs (x86, arm, mips) which would
> check and do:
>     if (isRecordWithNonTrivialDestructorOrCopyConstructor(Ty))
>       return ABIArgInfo::getIndirect(0, /*ByVal=*/false);
> to only have one temp copy. So, should the default not mark "byval"?
> LE32 / PNaCl is currently using the default, and we would like avoid the
> extra copy from the "byval" attribute. If the default should not be changed,
> is it okay to add an LE32ABIInfo (for le32 / PNaCl) which diverges from the
> DefaultABIInfo in this way (no "byval" attribute on the pointer for
> non-trivial c++ objects)? If this second approach (adding LE32ABIInfo) is
> acceptable, please see attached patch w/ tests for le32 changes.
> If the default should be changed, I can send another patch.

The default should probably be changed, given that passing a record
with a non-trivial copy constructor as byval can't possibly work.

-Eli




More information about the cfe-dev mailing list