--- Comment #2 from Jiong Wang <jiwang at gcc dot gnu.org> ---
(In reply to Eric Botcazou from comment #1)
> > I attached a simply fix to keep REG-NOTE order during insn copy.
> > Any comments?
> This seems reasonable if you need it for the DWARF CFI stuff, but note that
> emit_copy_of_insn_after is not the only place where notes are copied, e.g.
> try_split or create_copy_of_insn_rtx does that too.
Thanks for the comments Eric.
I am wondering whether it's OK to use copy_insn_1 here? that is to replace the
whole for loop into something simply as "REG_NOTES (new_insn) = copy_insn_1
(REG_NOTES (old_insn);" as I think copy_insn_1 will do recursive copy. This
is what's used in old reload1.c.
in emit_copy_of_insn_after, gcc is skipping REG_LABEL_OPERAND because it is
thinking the above mark_jump_label will generate that. My understanding is
it's also OK to copy from the source as they will be identical given the
CODE_LABEL is the same.
So copy_insn_1 is safe?
For the other two places, try_split will just return if the insn is
RTX_FRAME_RELATED_P, so should be OK.
/* We're not good at redistributing frame information. */
if (RTX_FRAME_RELATED_P (trial))
While for create_copy_of_insn_rtx in sel-sched-ir.c, I find those historical
discussion at https://gcc.gnu.org/ml/gcc-patches/2011-12/msg01232.html, it was
supposed to copy REG_ARGS_SIZE only, later extended to all except
REG_LABEL_OPERAND/REG_EQUAL/REG_EQUALV. There is actually no mark_jump_label
here, so I am thinking the skip of REG_LABEL_OPERAND is wrong, while I am not
sure if copying REG_EQUAL/REG_EQUALV is wrong.