]> git.ipfire.org Git - thirdparty/gcc.git/commit
cprop_hardreg: Prevent copy propagation from a non-frame related insn to a frame...
authorSurya Kumari Jangala <jskumari@linux.ibm.com>
Sun, 16 Nov 2025 17:11:06 +0000 (12:11 -0500)
committerSurya Kumari Jangala <jskumari@linux.ibm.com>
Sun, 14 Dec 2025 09:02:45 +0000 (04:02 -0500)
commitffa98429b93934be87f58bc3af481a69310aedaf
tree06710843d86969596ddc114223ffa0f34ff574ea
parent427ddf95eef8879b351672de15f227eec103dd42
cprop_hardreg: Prevent copy propagation from a non-frame related insn to a frame related insn

The pass 'cprop_hardreg' should not propagate a value from a
non-frame-related insn to a frame-related one. This can lead to
incorrect dwarf information as noted in PR122274.

cprop_hardreg uses 'struct value_data' to hold lists of registers that
contain the same value. However, the value data does not have any
information about the instruction that sets the values in the register.

In this patch, a new field is added to 'struct value_data_entry'
which indicates if the instruction that created this
value is frame related or not. Then during copy propagation, we do not
replace registers if the copy is happening from a non-frame related insn
to a frame related insn.

2025-11-16  Surya Kumari Jangala  <jskumari@linux.ibm.com>

gcc:
PR rtl-optimization/122274
* regcprop.cc (value_data_entry): New field.
(kill_value_one_regno): Update field.
(init_value_data): Initialize field.
(kill_set_value_data): New field.
(kill_set_value): Update field.
(kill_autoinc_value): Likewise.
(copy_value): New parameter. Update field.
(incompatible_frame_status): New function.
(find_oldest_value_reg): New parameter. Compare frame relatedness of
insn and propagated value.
(replace_oldest_value_reg): Pass additional parameter to
find_oldest_value_reg().
(copyprop_hardreg_forward_1): Pass additional parameter to
find_oldest_value_reg(). Compare frame relatedness of insn and
propagated value. Call copy_value() with additional parameter.

gcc/testsuite:
PR rtl-optimization/122274
* gcc.dg/rtl/powerpc/test-frame-related.c: New test.
gcc/regcprop.cc
gcc/testsuite/gcc.dg/rtl/powerpc/test-frame-related.c [new file with mode: 0644]