[Ada] Improve handling of explicit by-reference mechanism

Programming / Compilers / GCC - pmderodat [138bc75d-0d04-0410-961f-82ee72b054a4] - 19 September 2019 08:12 EDT

This improves the handling of an explicit by-reference passing mechanism specified by means of the GNAT pragma Export_Function. This device sort of circumvents the rules of the language for the by-reference passing mechanism and it's then up to the programmer to ensure that the actual parameter is addressable; if it is not, the compiler will generate a temporary around the call, thus effectively passing the actual by copy.

It turns out that the compiler was too conservative when determining whether the actual parameter is addressable, in particular if it's a component of a record type subject to a representation clause.

The change effectively moves this computation from the front-end to the back-end, which has much more information on the layout and alignment of types and thus can be less conservative.

2019-09-19 Eric Botcazou


- exp_ch6.adb (Is_Legal_Copy): Also return false for an aliased formal and a formal passed by reference in convention Ada. Add missing guard to the existing test on Is_Valued_Procedure.

ebec5184021 [Ada] Improve handling of explicit by-reference mechanism
gcc/ada/ChangeLog | 6 ++++++
gcc/ada/exp_ch6.adb | 11 ++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)

Upstream: gcc.gnu.org

  • Share