On 11/13/24 14:10, Denis Chertykov wrote:
The fix for PR117191
Wrong code appears after dse2 pass because it removes necessary insns.
(ie insn 554 - store to frame spill slot)
This happened because LRA pass doesn't cleanup the code exactly like
reload does.
The reload1.c has a special pass for such cleanup.
The reload removes CLOBBER insns with spill slots like this:
(insn 202 184 186 7 (clobber (mem/c:TI (plus:HI (reg/f:HI 28 r28)
(const_int 1 [0x1])) [3 %sfp+1 S16 A8])) -1
(nil))
I guess not all functionality of reload was implemented (e.g. support
for architecture with address in the memory address like vax). The same
happened with removing such clobbers. Implementation of LRA was a
process of simplification and finding what minimal functionality would work.
LRA have a similar place where it removes unnecessary insns, but not
CLOBBER insns with
memory spill slots. It's `lra_final_code_change' function.
I just mark a CLOBBER insn with pseudo spilled to memory for removing
it later together
with LRA temporary CLOBBER insns.
The patch is simple.
On x86_64, it bootstraps+regtests fine.
Ok for trunk?
Special clobbers with BLK mode can not be here and moreover memory for
spilled pseudo can not get BLK mode. So I think the patch is safe.
The patch is OK for me. Thank you for working on this issue.
PR rtl-optimization/117191
gcc/
* lra-spills.cc (spill_pseudos): Mark a CLOBBER insn with pseudo
spilled to memory for removing it later together with LRA temporary
CLOBBER insns.
diff --git a/gcc/lra-spills.cc b/gcc/lra-spills.cc
index c149c3388cd..3f5c8d2bcb0 100644
--- a/gcc/lra-spills.cc
+++ b/gcc/lra-spills.cc
@@ -537,6 +537,11 @@ spill_pseudos (void)
break;
}
}
+ if (GET_CODE (PATTERN (insn)) == CLOBBER)
+ /* This is a CLOBBER insn with pseudo spilled to memory.
+ Mark it for removing it later together with LRA temporary
+ CLOBBER insns. */
+ LRA_TEMP_CLOBBER_P (PATTERN (insn)) = 1;
if (lra_dump_file != NULL)
fprintf (lra_dump_file,
"Changing spilled pseudos to memory in insn #%u\n",