On Fri, 30 Oct 2020 at 20:11, Vladimir Makarov via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > The following patch implements taking insn scratch requirements into > account in global RA (IRA). Before the patch IRA simply ignored insn > scratches. Only LRA took the scratches into account and assigned hard > registers to scratches if neccessary. In some cases it resulted in > spilling pseudos who got hard registers in IRA and as a consequence in > violating a good IRA assignment. > > The patch changes insn scratches which require registers for all > insn alternatives (in other words w/o X constraint in scratch > constraint string). This is done before IRA staring its work. LRA > still continue to change the rest scratches (with X constraint and in > insn created during IRA) into pseudos. As before the patch at the end > of LRA work, spilled scratch pseudos (for which X constraint was > chosen) changed into scratches back. > > The patch was successfully bootstrapped and tested on x86-64, ppc64, > aarch64, s390x. There are few new GCC test failures on ppc64 and > s390x which can be fixed by adding hints to scratch constraints in ppc > md file and by changing expected test output (as hard register > assignment was changed a bit). I'll submit the patches for approval a > bit later. > > > 2020-10-30 Vladimir Makarov <vmaka...@redhat.com> > > * lra.c (get_scratch_reg): New function. > (remove_scratches_1): Rename remove_insn_scratches. Use > ira_remove_insn_scratches and get_scratch_reg. > (remove_scratches): Do not > initialize scratches, scratch_bitmap, and scratch_operand_bitmap. > (lra): Call ira_restore_scratches instead of restore_scratches. > (struct sloc, sloc_t, scratches, scratch_bitmap) > (scratch_operand_bitmap, lra_former_scratch_p) > (lra_former_scratch_operand_p, lra_register_new_scratch_op, > restore_scratches): Move them to ... > * ira.c: ... here. > (former_scratch_p, former_scratch_operand_p): Rename to > ira_former_scratch_p and ira_former_scratch_operand_p. > (contains_X_constraint_p): New function. > (register_new_scratch_op): Rename to ira_register_new_scratch_op. > Change it to work for IRA and LRA. > (restore_scratches): Rename to ira_restore_scratches. > (get_scratch_reg, ira_remove_insn_scratches): New functions. > (ira): Call ira_remove_scratches if we use LRA. > * ira.h (ira_former_scratch_p, ira_former_scratch_operand_p): New > prototypes. > (ira_register_new_scratch_op, ira_restore_scratches): New > prototypes. > (ira_remove_insn_scratches): New prototype. > * lra-int.h (lra_former_scratch_p, lra_former_scratch_operand_p): > Remove prototypes. > (lra_register_new_scratch_op): Ditto. > * lra-constraints.c: Rename lra_former_scratch_p and > lra_former_scratch_p to ira_former_scratch_p and to > ira_former_scratch_p. > * lra-remat.c: Ditto. > * lra-spills.c: Rename lra_former_scratch_p to > ira_former_scratch_p. >
Hi, This patch causes ICEs on arm (eg arm-none-linux-gnueabi) gcc.c-torture/compile/sync-3.c -O1 (internal compiler error) gcc.c-torture/compile/sync-3.c -O2 (internal compiler error) gcc.c-torture/compile/sync-3.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (internal compiler error) gcc.c-torture/compile/sync-3.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (internal compiler error) gcc.c-torture/compile/sync-3.c -O3 -g (internal compiler error) gcc.c-torture/compile/sync-3.c -Os (internal compiler error) gcc.log says: FAIL: gcc.c-torture/compile/sync-3.c -O1 (internal compiler error) PASS: gcc.c-torture/compile/sync-3.c -O1 (test for warnings, line ) FAIL: gcc.c-torture/compile/sync-3.c -O1 (test for excess errors) Excess errors: during RTL pass: ira /gcc/testsuite/gcc.c-torture/compile/sync-3.c:85:1: internal compiler error: Segmentation fault 0xcf8b1f crash_signal /gcc/toplev.c:330 0xaeb0a0 fix_reg_equiv_init /gcc/ira.c:2671 0xaf2113 find_moveable_pseudos /gcc/ira.c:4874 0xaf48e8 ira /gcc/ira.c:5533 0xaf48e8 execute /gcc/ira.c:5861 FAIL: gcc.c-torture/compile/sync-3.c -O2 (internal compiler error) PASS: gcc.c-torture/compile/sync-3.c -O2 (test for warnings, line ) FAIL: gcc.c-torture/compile/sync-3.c -O2 (test for excess errors) Excess errors: during RTL pass: ira /gcc/testsuite/gcc.c-torture/compile/sync-3.c:85:1: internal compiler error: Segmentation fault 0xcf8b1f crash_signal /gcc/toplev.c:330 0xaeb0a9 safe_as_a<rtx_insn_list*, rtx_def> /gcc/is-a.h:210 0xaeb0a9 rtx_insn_list::next() const /gcc/rtl.h:1408 0xaeb0a9 fix_reg_equiv_init /gcc/ira.c:2683 0xaf2113 find_moveable_pseudos /gcc/ira.c:4874 0xaf48e8 ira /gcc/ira.c:5533 0xaf48e8 execute /gcc/ira.c:5861 Christophe