https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110378
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Martin Jambor <jamb...@gcc.gnu.org>: https://gcc.gnu.org/g:14d0c509898b0361f78284c05556035edde6d1e0 commit r14-4383-g14d0c509898b0361f78284c05556035edde6d1e0 Author: Martin Jambor <mjam...@suse.cz> Date: Tue Oct 3 18:44:52 2023 +0200 ipa-sra: Allow IPA-SRA in presence of returns which will be removed Testing on 32bit arm revealed that even the simplest case of PR 110378 was still not resolved there because destructors were rturning this pointer. Needless to say, the return value of those destructors often is just not used, which IPA-SRA can already detect in time. Since such enhancement seems generally useful, here it is. The patch simply adds two flag to respective summaries to mark down situations when it encounters either a simple direct use of a defaut definition SSA_NAME of a paramter, which means that the parameter may still be split when rturn value is removed, and when any derived use of it is returned, allowing for complete removal in that case, instead of discarding it as a candidate for removal or splitting like we do now. The IPA phase then simply checks that we indeed plan to remove the return value before allowing any transformation to be considered in such cases. gcc/ChangeLog: 2023-08-18 Martin Jambor <mjam...@suse.cz> PR ipa/110378 * ipa-param-manipulation.cc (ipa_param_body_adjustments::mark_dead_statements): Verify that any return uses of PARAM will be removed. (ipa_param_body_adjustments::mark_clobbers_dead): Likewise. * ipa-sra.cc (isra_param_desc): New fields remove_only_when_retval_removed and split_only_when_retval_removed. (struct gensum_param_desc): Likewise. Fix comment long line. (ipa_sra_function_summaries::duplicate): Copy the new flags. (dump_gensum_param_descriptor): Dump the new flags. (dump_isra_param_descriptor): Likewise. (isra_track_scalar_value_uses): New parameter desc. Set its flag remove_only_when_retval_removed when encountering a simple return. (isra_track_scalar_param_local_uses): Replace parameter call_uses_p with desc. Pass it to isra_track_scalar_value_uses and set its call_uses. (ptr_parm_has_nonarg_uses): Accept parameter descriptor as a parameter. If there is a direct return use, mark any.. (create_parameter_descriptors): Pass the whole parameter descriptor to isra_track_scalar_param_local_uses and ptr_parm_has_nonarg_uses. (process_scan_results): Copy the new flags. (isra_write_node_summary): Stream the new flags. (isra_read_node_info): Likewise. (adjust_parameter_descriptions): Check that transformations requring return removal only happen when return value is removed. Restructure main loop. Adjust dump message. gcc/testsuite/ChangeLog: 2023-08-18 Martin Jambor <mjam...@suse.cz> PR ipa/110378 * gcc.dg/ipa/ipa-sra-32.c: New test. * gcc.dg/ipa/pr110378-4.c: Likewise. * gcc.dg/ipa/ipa-sra-4.c: Use a return value.