>
> Andrew Pinski <[EMAIL PROTECTED]> writes:
>
> > >
> > > > Hi,
> > > > thanks for testing. I've bootstrapped/regtested this variant of patch
> > > > and comitted it as obvious.
> > >
> > > Since this is an insn, we should not be copying it as it is just a link
> > > to that
> > > insn.
> > >
> > > Attached is a patch which fixes the ICE though I have not bootstrapped
> > > and tested
> > > it yet.
> >
> > Lets try to attach the patch this time.
>
> It seems to me this code should just be
>
> for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
> if (REG_NOTE_KIND (link) != REG_LABEL)
> {
> if (GET_CODE (link) == EXPR_LIST)
> REG_NOTES (new)
> = gen_rtx_EXPR_LIST (REG_NOTE_KIND (link),
> copy_rtx (XEXP (link, 0)), REG_NOTES (new));
> else
> REG_NOTES (new)
> = gen_rtx_INSN_LIST (REG_NOTE_KIND (link),
> copy_rtx (XEXP (link, 0)), REG_NOTES (new));
> }
>
> What do we expect to find in a REG_NOTE that requires the machinery of
> copy_insn_1? And calling copy_insn_1 without going through copy_insn
> looks very wrong.
Here is a better patch which also speeds up this code by fixing up
the libcall notes in that loop.
I tested it on the preprocessed source that Andreas sent me but
I don't have time to do a full bootstrap till tommorrow.
ChangeLog:
* emit-rtl.c (emit_copy_of_insn_after): Copy REG_LIBCALL note specially.
Copy REG_RETVAL not specially and fix it and the referencing
REG_LIBCALL note.
Use copy_rtx instead of copy_insn_1 for EXPR_LIST note.
Abort if we get a INSN_LIST for the note.
Thanks,
Andrew Pinski
Index: emit-rtl.c
===================================================================
--- emit-rtl.c (revision 120287)
+++ emit-rtl.c (working copy)
@@ -5255,7 +5255,7 @@
emit_copy_of_insn_after (rtx insn, rtx after)
{
rtx new;
- rtx note1, note2, link;
+ rtx note2, link;
switch (GET_CODE (insn))
{
@@ -5295,25 +5295,30 @@
for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
if (REG_NOTE_KIND (link) != REG_LABEL)
{
- if (GET_CODE (link) == EXPR_LIST)
+ /* REG_LIBCALL will be fixed up when the insn with REG_RETVAL is
added. */
+ if (REG_NOTE_KIND (link) == REG_LIBCALL)
+ REG_NOTES (new) = gen_rtx_INSN_LIST (REG_NOTE_KIND (link),
+ XEXP (link, 0), REG_NOTES (new));
+ /* Copy REG_RETVAL and fix up it and the previous REG_LIBCALL at the
same time. */
+ else if (REG_NOTE_KIND (link) == REG_RETVAL)
+ {
+ rtx p = new;
+ /* Find the previous REG_LIBCALL which had the old original in it.
*/
+ while ((note2 = find_reg_note (p, REG_LIBCALL, NULL_RTX)) == NULL
+ || XEXP (note2, 0) != insn)
+ p = PREV_INSN (p);
+ XEXP (note2, 0) = new;
+ REG_NOTES (new) = gen_rtx_INSN_LIST (REG_NOTE_KIND (link),
+ p, REG_NOTES (new));
+ }
+ else if (GET_CODE (link) == EXPR_LIST)
REG_NOTES (new)
= gen_rtx_EXPR_LIST (REG_NOTE_KIND (link),
- copy_insn_1 (XEXP (link, 0)), REG_NOTES (new));
+ copy_rtx (XEXP (link, 0)), REG_NOTES (new));
else
- REG_NOTES (new)
- = gen_rtx_INSN_LIST (REG_NOTE_KIND (link),
- copy_insn_1 (XEXP (link, 0)), REG_NOTES (new));
+ gcc_unreachable ();
}
- /* Fix the libcall sequences. */
- if ((note1 = find_reg_note (new, REG_RETVAL, NULL_RTX)) != NULL)
- {
- rtx p = new;
- while ((note2 = find_reg_note (p, REG_LIBCALL, NULL_RTX)) == NULL)
- p = PREV_INSN (p);
- XEXP (note1, 0) = p;
- XEXP (note2, 0) = new;
- }
INSN_CODE (new) = INSN_CODE (insn);
return new;
}