]> git.ipfire.org Git - thirdparty/gcc.git/commit
ipa-sra: Allow IPA-SRA in presence of returns which will be removed
authorMartin Jambor <mjambor@suse.cz>
Tue, 3 Oct 2023 16:44:52 +0000 (18:44 +0200)
committerMartin Jambor <mjambor@suse.cz>
Tue, 3 Oct 2023 16:48:55 +0000 (18:48 +0200)
commit14d0c509898b0361f78284c05556035edde6d1e0
tree3e3bcfa15d378771fb46555f92a5ba87dd5b97d1
parent1be18ea110a2d69570dbc494588a7c73173883be
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  <mjambor@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  <mjambor@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.
gcc/ipa-param-manipulation.cc
gcc/ipa-sra.cc
gcc/testsuite/gcc.dg/ipa/ipa-sra-32.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/ipa/ipa-sra-4.c
gcc/testsuite/gcc.dg/ipa/pr110378-4.c [new file with mode: 0644]