Martin Jambor 1be18ea110 ipa: Self-DCE of uses of removed call LHSs (PR 108007)
PR 108007 is another manifestation where we rely on DCE to clean-up
after IPA-SRA and if the user explicitely switches DCE off, IPA-SRA
can leave behind statements which are fed uninitialized values and
trap, even though their results are themselves never used.

I have already fixed this for unused parameters in callees, this bug
shows that almost the same thing can happen for removed returns, on
the side of callers.  This means that the issue has to be fixed
elsewhere, in call redirection.  This patch adds a function which
looks for (and through, using a work-list) uses of operations fed
specific SSA names and removes them all.

That would have been easy if it wasn't for debug statements during
tree-inline (from which call redirection is also invoked).  Debug
statements are decoupled from the rest at this point and iterating
over uses of SSAs does not bring them up.  During tree-inline they are
handled especially at the end, I assume in order to make sure that
relative ordering of UIDs are the same with and without debug info.

This means that during tree-inline we need to make a hash of killed
SSAs, that we already have in copy_body_data, available to the
function making the purging.  So the patch duly does also that, making
the interface slightly ugly.

gcc/ChangeLog:

2023-09-27  Martin Jambor  <mjambor@suse.cz>

	PR ipa/108007
	* cgraph.h (cgraph_edge): Add a parameter to
	redirect_call_stmt_to_callee.
	* ipa-param-manipulation.h (ipa_param_adjustments): Add a
	parameter to modify_call.
	* cgraph.cc (cgraph_edge::redirect_call_stmt_to_callee): New
	parameter killed_ssas, pass it to padjs->modify_call.
	* ipa-param-manipulation.cc (purge_transitive_uses): New function.
	(ipa_param_adjustments::modify_call): New parameter killed_ssas.
	Instead of substituting uses, invoke purge_transitive_uses.  If
	hash of killed SSAs has not been provided, create a temporary one
	and release SSAs that have been added to it.
	* tree-inline.cc (redirect_all_calls): Create
	id->killed_new_ssa_names earlier, pass it to edge redirection,
	adjust a comment.
	(copy_body): Release SSAs in id->killed_new_ssa_names.

gcc/testsuite/ChangeLog:

2023-05-11  Martin Jambor  <mjambor@suse.cz>

	PR ipa/108007
	* gcc.dg/ipa/pr108007.c: New test.
2023-10-03 18:48:41 +02:00
2023-09-16 00:17:55 +00:00
2023-10-03 00:17:22 +00:00
2023-08-18 00:16:52 +00:00
2023-08-23 00:17:59 +00:00
2023-08-08 00:17:37 +00:00
2023-08-08 00:17:37 +00:00
2023-08-08 00:17:37 +00:00
2023-08-08 00:17:37 +00:00
2023-08-12 00:17:36 +00:00
2023-09-21 00:17:49 +00:00
2023-08-24 00:18:18 +00:00
2023-09-28 09:50:12 +00:00
2023-09-29 00:17:28 +00:00
2023-09-30 00:17:24 +00:00
2023-09-21 00:17:49 +00:00
2023-08-23 00:17:59 +00:00
2023-08-08 00:17:37 +00:00
2023-08-08 00:17:37 +00:00
2023-09-24 00:16:58 +00:00
2023-08-08 00:17:37 +00:00
2023-08-08 00:17:37 +00:00
2023-08-08 00:17:37 +00:00
2023-09-30 00:17:24 +00:00
2023-08-08 00:17:37 +00:00
2023-08-08 00:17:37 +00:00
2023-08-08 00:17:37 +00:00
2023-09-19 00:17:49 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 4.2 GiB
Languages
C++ 30.7%
C 30.2%
Ada 14.4%
D 6.1%
Go 5.7%
Other 12.4%