]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Fix suboptimal copy of discriminated record to local variable
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 16 Dec 2025 11:30:14 +0000 (12:30 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 9 Jan 2026 10:57:22 +0000 (11:57 +0100)
commit571f250c66150301bebad35e9c8dac3169593acb
treec35dbe434d108ddf4d26842a0bf78ace76e937e9
parent4e1468b9ff374445c854ca35e1d9cbc925cda1f7
ada: Fix suboptimal copy of discriminated record to local variable

This happens for a discriminated record type with default discriminants, for
which GNAT allocates mutable objects with the maximum size, while trying not
to copy padding bits unnecessarily.  When the padded size is small enough to
be copied efficiently, it should nevertheless be profitable to copy them in
order to avoid a call to memcpy with a dynamic size.

gcc/ada/ChangeLog:

* gcc-interface/trans.cc (gnat_to_gnu): For the LHS of an assignment
or an actual parameter of a call, do not remove the padding even for
a type of self-referential size when the padded size is small enough
to be copied efficiently.
gcc/ada/gcc-interface/trans.cc