]> git.ipfire.org Git - people/ms/gcc.git/commit
ada: Optimize interface objects initialized with function calls
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 28 Dec 2022 16:36:32 +0000 (17:36 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 16 Jan 2023 14:44:54 +0000 (15:44 +0100)
commit8daf80ff0ecd2aee50bf8e4f0f0dda906aeb190d
treec459c050e664056134b0efb0e5e81fdd5e4f3335
parent967592488c64a86f37bef3dabebb56364f14acdd
ada: Optimize interface objects initialized with function calls

This optimizes the implementation of (class-wide) interface objects that are
initialized with function calls, by avoiding an unnecessary copy operation.
This also removes useless access checks generated by the expansion of return
statements involving class-wide types.

gcc/ada/

* exp_ch3.adb (Expand_N_Object_Declaration): Factor out conditions
needed for an initializating expression that is a function call to
be renamable into the Is_Renamable_Function_Call predicate.
Use it to implement the renaming in the case of class-wide interface
objects.  Remove an interface conversion on all paths, separate and
optimize the renaming path in the special expansion for interfaces.
(Is_Renamable_Function_Call): New predicate.
(Make_Allocator_For_Return): Put back an interface conversion.
* exp_ch6.adb (Apply_CW_Accessibility_Check): Remove useless access
checks on RE_Tag_Ptr.
gcc/ada/exp_ch3.adb
gcc/ada/exp_ch6.adb