ada: Make detection of useless copy for return more robust
commitd851e08ba97f5d0671711763f6a7d4c94afb8457
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 12 Mar 2024 16:56:00 +0000 (12 17:56 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 21 May 2024 07:27:57 +0000 (21 09:27 +0200)
tree3a04c43ec6b2c1fbbb6a655513ce47384b7dee09
parentf20a57edefe0cb185e57f82a15e887887b98d3ab
ada: Make detection of useless copy for return more robust

In the return-by-invisible-reference case, the return object of an extended
return statement is allocated directly on the return stack and, therefore,
the copy operation on return is useless.  The code detecting this was not
robust enough and missed some complex cases.

gcc/ada/

* gcc-interface/trans.cc (gnat_to_gnu) <N_Simple_Return_Statement>:
In the return-by-invisible-reference case, remove conversions before
looking for a dereference in the return values and building the test
protecting against a useless copy operation.
gcc/ada/gcc-interface/trans.cc