]> git.ipfire.org Git - thirdparty/gcc.git/commit
rtl-ssa: Fix -fcompare-debug failure [PR100303]
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 4 Jun 2024 12:47:36 +0000 (13:47 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 4 Jun 2024 12:47:36 +0000 (13:47 +0100)
commita1fb76e041740e7dd8cdf71dff3ae7aa31b3ea9b
treedd9ef8ab1b712b13ab92fef5a109e077c3263977
parent66d01cc3f4a248ccc471a978f0bfe3615c3f3a30
rtl-ssa: Fix -fcompare-debug failure [PR100303]

This patch fixes an oversight in the handling of debug instructions
in rtl-ssa.  At the moment (and whether this is a good idea or not
remains to be seen), we maintain a linear RPO sequence of definitions
and non-debug uses.  If a register is defined more than once, we use
a degenerate phi to reestablish a previous definition where necessary.

However, debug instructions shouldn't of course affect codegen,
so we can't create a new definition just for them.  In those situations
we instead hang the debug use off the real definition (meaning that
debug uses do not follow a linear order wrt definitions).  Again,
it remains to be seen whether that's a good idea.

The problem in the PR was that we weren't taking this into account
when increasing (or potentially increasing) the live range of an
existing definition.  We'd create the phi even if it would only
be used by debug instructions.

The patch goes for the simple but inelegant approach of passing
a bool to say whether the use is a debug use or not.  I imagine
this area will need some tweaking based on experience in future.

gcc/
PR rtl-optimization/100303
* rtl-ssa/accesses.cc (function_info::make_use_available): Take a
boolean that indicates whether the use will only be used in
debug instructions.  Treat it in the same way that existing
cross-EBB debug references would be handled if so.
(function_info::make_uses_available): Likewise.
* rtl-ssa/functions.h (function_info::make_uses_available): Update
prototype accordingly.
(function_info::make_uses_available): Likewise.
* fwprop.c (try_fwprop_subst): Update call accordingly.

(cherry picked from commit c97351c0cf4872cc0e99e73ed17fb16659fd38b3)
gcc/fwprop.c
gcc/rtl-ssa/accesses.cc
gcc/rtl-ssa/functions.h
gcc/testsuite/g++.dg/torture/pr100303.C [new file with mode: 0644]