This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/11162] new-ra bug
- From: "matz at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Jun 2003 06:08:58 -0000
- Subject: [Bug optimization/11162] new-ra bug
- References: <20030611222319.11162.tm@kloo.net>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11162
------- Additional Comments From matz@suse.de 2003-06-12 06:08 -------
Subject: Re: new-ra bug
On 11 Jun 2003, rth@gcc.gnu.org wrote:
> Moreover, I can't figure out why the USE is being added at all.
Crappy obsolete design ;-) I didn't use mark_regs_live_at_end() to force
the return register live at the end, partly because I can basically only
deal with real register references (the flow.c code simply sets some bits
in the liveness bitmaps). But it needs to be made live somehow, hence I
simply added such fake uses. In the new-ra branch I added code to delete
these instructions after allocation again. (Or rather I would have had,
had I committed ;( ). Like the below patch. It also fixes the testcase.
Somewhen I need to go over this again, to use something similar to the
mark_regs_live_at_end() function, because this method is bound to break
(for instance I only add the return value use, but not all the other regs
which that function might add).
Index: ra.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra.c,v
retrieving revision 1.8
diff -u -p -r1.8 ra.c
--- ra.c 7 Mar 2003 22:06:16 -0000 1.8
+++ ra.c 12 Jun 2003 06:06:03 -0000
@@ -669,6 +669,7 @@ reg_alloc ()
int changed;
FILE *ra_dump_file = rtl_dump_file;
rtx last = get_last_insn ();
+ bitmap use_insns = BITMAP_XMALLOC ();
if (! INSN_P (last))
last = prev_real_insn (last);
@@ -686,11 +687,13 @@ reg_alloc ()
last = bb->end;
if (!INSN_P (last) || GET_CODE (PATTERN (last)) != USE)
{
- rtx insns;
+ rtx insn, insns;
start_sequence ();
use_return_register ();
insns = get_insns ();
end_sequence ();
+ for (insn = insns; insn; insn = NEXT_INSN (insn))
+ bitmap_set_bit (use_insns, INSN_UID (insn));
emit_insn_after (insns, last);
}
}
@@ -868,6 +871,22 @@ reg_alloc ()
no_new_pseudos = 1;
rtl_dump_file = ra_dump_file;
+ {
+ edge e;
+ for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+ {
+ basic_block bb = e->src;
+ last = bb->end;
+ for (last = bb->end; last; last = PREV_INSN (last))
+ {
+ if (last == bb->head)
+ break;
+ if (bitmap_bit_p (use_insns, INSN_UID (last)))
+ delete_insn (last);
+ }
+ }
+ }
+ BITMAP_XFREE (use_insns);
/* Some spill insns could've been inserted after trapping calls, i.e.
at the end of a basic block, which really ends at that call.
Fixup that breakages by adjusting basic block boundaries. */