This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
RFA: Add locators to reloads
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: gdb at sources dot redhat dot com
- Date: Fri, 16 Jan 2004 10:43:14 -0500
- Subject: RFA: Add locators to reloads
It used to be that the line notes were used to indicate line numbers. This
meant that if you did emit_insn_before or emit_insn_after, you picked up the
same line number as the insn you were using as an anchor. Now, we already
have locators set by this time, so that's not true any more.
I was going to change emit_insn_before and friends, but Honza asked me not
to; for some insns there's no clear location, f.ex. insns inserted on an
edge, so he didn't like the idea of defaulting to the anchor's locator.
So I added variants which did, and used them where appropriate in reload,
since reloads have a clear associated instruction.
The GDB test case this fixes looks like this:
register charest l = u, r = v;
l = add_charest (l, r);
return l + r;
We get (from memory, I apologize for my ARM syntax):
bl add_charest
str r0, [fp - 20]
ldr r0, [fp - 20]
.loc 1 20 0
add r0, r0, r1
But what we should get is:
bl add_charest
str r0, [fp - 20]
.loc 1 20 0
ldr r0, [fp - 20]
add r0, r0, r1
It makes a difference because, without location lists, we're telling GDB
that the variable l lives at [fp - 20]. So the user sets it:
(gdb) set var l = 4
and then steps; but the stale value of l is returned.
This is also a regression from 3.3. OK for 3.4?
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2004-01-15 Daniel Jacobowitz <drow@mvista.com>
* rtl.h (emit_insn_before_sameloc, emit_jump_insn_before_sameloc)
(emit_call_insn_before_sameloc, emit_insn_after_sameloc)
(emit_jump_insn_after_sameloc, emit_call_insn_after_sameloc): New
macros.
* reload1.c (emit_reload_insns): Use them.
* emit-rtl.c (emit_insn_before_sameloc, emit_insn_after_sameloc)
(emit_jump_insn_after_sameloc, emit_call_insn_after_sameloc): Check
for NULL PATTERN.
Index: rtl.h
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/rtl.h,v
retrieving revision 1.437.4.1
diff -u -p -r1.437.4.1 rtl.h
--- rtl.h 23 Dec 2003 22:08:04 -0000 1.437.4.1
+++ rtl.h 15 Jan 2004 22:14:40 -0000
@@ -1,6 +1,6 @@
/* Register Transfer Language (RTL) definitions for GCC
Copyright (C) 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GCC.
@@ -1573,6 +1573,19 @@ extern rtx prev_label (rtx);
extern rtx next_label (rtx);
extern rtx next_cc0_user (rtx);
extern rtx prev_cc0_setter (rtx);
+
+#define emit_insn_before_sameloc(INSN, BEFORE) \
+ emit_insn_before_setloc (INSN, BEFORE, INSN_LOCATOR (BEFORE))
+#define emit_jump_insn_before_sameloc(INSN, BEFORE) \
+ emit_jump_insn_before_setloc (INSN, BEFORE, INSN_LOCATOR (BEFORE))
+#define emit_call_insn_before_sameloc(INSN, BEFORE) \
+ emit_call_insn_before_setloc (INSN, BEFORE, INSN_LOCATOR (BEFORE))
+#define emit_insn_after_sameloc(INSN, AFTER) \
+ emit_insn_after_setloc (INSN, AFTER, INSN_LOCATOR (AFTER))
+#define emit_jump_insn_after_sameloc(INSN, AFTER) \
+ emit_jump_insn_after_setloc (INSN, AFTER, INSN_LOCATOR (AFTER))
+#define emit_call_insn_after_sameloc(INSN, AFTER) \
+ emit_call_insn_after_setloc (INSN, AFTER, INSN_LOCATOR (AFTER))
/* In cfglayout.c */
extern tree choose_inner_scope (tree, tree);
Index: emit-rtl.c
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/emit-rtl.c,v
retrieving revision 1.351.4.1
diff -u -p -r1.351.4.1 emit-rtl.c
--- emit-rtl.c 23 Dec 2003 22:07:50 -0000 1.351.4.1
+++ emit-rtl.c 15 Jan 2004 22:14:48 -0000
@@ -4666,6 +4666,9 @@ emit_insn_after_setloc (rtx pattern, rtx
{
rtx last = emit_insn_after (pattern, after);
+ if (pattern == NULL_RTX)
+ return last;
+
after = NEXT_INSN (after);
while (1)
{
@@ -4684,6 +4687,9 @@ emit_jump_insn_after_setloc (rtx pattern
{
rtx last = emit_jump_insn_after (pattern, after);
+ if (pattern == NULL_RTX)
+ return last;
+
after = NEXT_INSN (after);
while (1)
{
@@ -4702,6 +4708,9 @@ emit_call_insn_after_setloc (rtx pattern
{
rtx last = emit_call_insn_after (pattern, after);
+ if (pattern == NULL_RTX)
+ return last;
+
after = NEXT_INSN (after);
while (1)
{
@@ -4720,6 +4729,9 @@ emit_insn_before_setloc (rtx pattern, rt
{
rtx first = PREV_INSN (before);
rtx last = emit_insn_before (pattern, before);
+
+ if (pattern == NULL_RTX)
+ return last;
first = NEXT_INSN (first);
while (1)
Index: reload1.c
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/reload1.c,v
retrieving revision 1.407.4.1
diff -u -p -r1.407.4.1 reload1.c
--- reload1.c 23 Dec 2003 22:08:03 -0000 1.407.4.1
+++ reload1.c 15 Jan 2004 21:56:23 -0000
@@ -1,6 +1,6 @@
/* Reload pseudo regs into hard regs for insns that require hard regs.
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GCC.
@@ -6963,25 +6963,25 @@ emit_reload_insns (struct insn_chain *ch
reloads for the operand. The RELOAD_OTHER output reloads are
output in descending order by reload number. */
- emit_insn_before (other_input_address_reload_insns, insn);
- emit_insn_before (other_input_reload_insns, insn);
+ emit_insn_before_sameloc (other_input_address_reload_insns, insn);
+ emit_insn_before_sameloc (other_input_reload_insns, insn);
for (j = 0; j < reload_n_operands; j++)
{
- emit_insn_before (inpaddr_address_reload_insns[j], insn);
- emit_insn_before (input_address_reload_insns[j], insn);
- emit_insn_before (input_reload_insns[j], insn);
+ emit_insn_before_sameloc (inpaddr_address_reload_insns[j], insn);
+ emit_insn_before_sameloc (input_address_reload_insns[j], insn);
+ emit_insn_before_sameloc (input_reload_insns[j], insn);
}
- emit_insn_before (other_operand_reload_insns, insn);
- emit_insn_before (operand_reload_insns, insn);
+ emit_insn_before_sameloc (other_operand_reload_insns, insn);
+ emit_insn_before_sameloc (operand_reload_insns, insn);
for (j = 0; j < reload_n_operands; j++)
{
- rtx x = emit_insn_after (outaddr_address_reload_insns[j], insn);
- x = emit_insn_after (output_address_reload_insns[j], x);
- x = emit_insn_after (output_reload_insns[j], x);
- emit_insn_after (other_output_reload_insns[j], x);
+ rtx x = emit_insn_after_sameloc (outaddr_address_reload_insns[j], insn);
+ x = emit_insn_after_sameloc (output_address_reload_insns[j], x);
+ x = emit_insn_after_sameloc (output_reload_insns[j], x);
+ emit_insn_after_sameloc (other_output_reload_insns[j], x);
}
/* For all the spill regs newly reloaded in this instruction,