]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/lra-int.h
[PR112445][LRA]: Fix "unable to find a register to spill" error
authorVladimir N. Makarov <vmakarov@redhat.com>
Fri, 1 Dec 2023 16:46:37 +0000 (11:46 -0500)
committerVladimir N. Makarov <vmakarov@redhat.com>
Fri, 1 Dec 2023 16:53:54 +0000 (11:53 -0500)
commit1390bf52c17a71834a1766c0222e4f8a74efb162
treed0446ffb6db04383a6fbed54d36cce443ac20a33
parentff99671ac3ea583a9d65c8c3cd3ff4aad1d68592
[PR112445][LRA]: Fix "unable to find a register to spill" error

PR112445 is a very complicated bug occurring from interaction of
constraint subpass, inheritance, and hard reg live range splitting.
It is hard to debug this PR only from LRA standard logs.  Therefore I
added dumping all func insns at the end of complicated sub-passes
(constraint, inheritance, undoing inheritance, hard reg live range
splitting, and rematerialization).  As such output can be quite big,
it is switched only one level 7 of -fira-verbose value.  The reason
for the bug is a skip of live-range splitting of hard reg (dx) on the
1st live range splitting subpass.  Splitting is done for reload
pseudos around an original insn and its reload insns but the subpass
did not recognize such insn pattern because previous inheritance and
undoing inheritance subpasses extended a bit reload pseudo live range.
Although we undid inheritance in question, the result code was a bit
different from a code before the corresponding inheritance pass.  The
following fixes the bug by restoring exact code before the
inheritance.

gcc/ChangeLog:

PR target/112445
* lra.h (lra): Add one more arg.
* lra-int.h (lra_verbose, lra_dump_insns): New externals.
(lra_dump_insns_if_possible): Ditto.
* lra.cc (lra_dump_insns): Dump all insns.
(lra_dump_insns_if_possible):  Dump all insns for lra_verbose >= 7.
(lra_verbose): New global.
(lra): Add new arg.  Setup lra_verbose from its value.
* lra-assigns.cc (lra_split_hard_reg_for): Dump insns if rtl
was changed.
* lra-remat.cc (lra_remat): Dump insns if rtl was changed.
* lra-constraints.cc (lra_inheritance): Dump insns.
(lra_constraints, lra_undo_inheritance): Dump insns if rtl
was changed.
(remove_inheritance_pseudos): Use restore reg if it is set up.
* ira.cc: (lra): Pass internal_flag_ira_verbose.

gcc/testsuite/ChangeLog:

PR target/112445
* gcc.target/i386/pr112445.c: New test.
gcc/ira.cc
gcc/lra-assigns.cc
gcc/lra-constraints.cc
gcc/lra-int.h
gcc/lra-remat.cc
gcc/lra.cc
gcc/lra.h
gcc/testsuite/gcc.target/i386/pr112445.c [new file with mode: 0644]