https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122274
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Surya Kumari Jangala <[email protected]>: https://gcc.gnu.org/g:ffa98429b93934be87f58bc3af481a69310aedaf commit r16-6109-gffa98429b93934be87f58bc3af481a69310aedaf Author: Surya Kumari Jangala <[email protected]> Date: Sun Nov 16 12:11:06 2025 -0500 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 <[email protected]> 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.
