Remove variables only used with .DEFERRED_INIT
authorRichard Biener <rguenther@suse.de>
Tue, 14 Mar 2023 08:42:45 +0000 (09:42 +0100)
committerRichard Biener <rguenther@suse.de>
Tue, 14 Mar 2023 12:46:30 +0000 (13:46 +0100)
commitbd6e566e9dc543cf4f6df69dcefb40bb8b4100f1
treecf763b71e176fddae80cf7af4d80c2f8704e20f2
parent67839c562779081936cb79ebca156ef43d70f65f
Remove variables only used with .DEFERRED_INIT

In PR109087 it was noticed that we rely on DSE to remove .DEFERRED_INIT
when it is the only remaining use of a variable.  Since DSE is imperfect
and even if it were not would be limited by the amount of statements to
walk the following enhances the unused var removal pass to handle
.DEFERRED_INIT like CLOBBERs, thus we do not keep local variables just
because they are deferred initialized.

* tree-ssa-live.cc (remove_unused_locals): Do not treat
the .DEFERRED_INIT of a variable as use, instead remove
that if it is the only use.

* gcc.dg/auto-init-unused-1.c: New testcase.
gcc/testsuite/gcc.dg/auto-init-unused-1.c [new file with mode: 0644]
gcc/tree-ssa-live.cc