Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@mvista.com>
To: gcc-patches@gcc.gnu.org
Cc: gdb@sources.redhat.com
Subject: RFA: Add locators to reloads
Date: Fri, 16 Jan 2004 15:43:00 -0000	[thread overview]
Message-ID: <20040116154314.GA30064@nevyn.them.org> (raw)

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,


             reply	other threads:[~2004-01-16 15:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-16 15:43 Daniel Jacobowitz [this message]
2004-01-16 20:17 ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040116154314.GA30064@nevyn.them.org \
    --to=drow@mvista.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gdb@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox