PATCH: Fix -xauto for ia64 assembler

H. J. Lu hjl@lucon.org
Fri May 28 06:09:00 GMT 2004


On Thu, May 27, 2004 at 01:59:17PM -0700, Jim Wilson wrote:
> On Thu, 2004-05-20 at 11:48, H. J. Lu wrote:
> > 	* config/tc-ia64.c (remove_marked_resource): Restore the old
> > 	operands when inserting srlz.i/srlz.d.
> 
> I had looked at this bug, but didn't get as far as trying to write a
> patch.  What bothers me here is that we have a structure with a lot of
> fields, and we are only moving two of them when we insert the new
> instruction.  Your patch modifies to code to move one more.  Shouldn't
> we be moving all of the fields instead of just a few of them?
> 
> I can make examples that fail in other ways if I add code that sets some
> of the other fields.  For example:
>         mov rr[r3]=r7
> [L2:]
>         ld8 r39 = [r35]
> The srlz.d instruction gets added in between the tag L2 and the ld8
> instruction.  I think it should be added in between the mov and the tag
> L2.
> 
> Another example:
>         .text
>         .global sub#
>         .proc sub#
> sub:
>         .prologue
>         mov rr[r3]=r7
>         .save rp, r4
>         ld8 r39 = [r35]
>         .endp sub#
> If you assemble this with -xauto, and and look at the unwind info, you
> can see that the .save unwind directive now points at the srlz.d
> instruction, which is bad. The .save unwind directive must be moved with
> the instruction that it belongs to.  This is a fake example, as we can't
> use .save rp with a ld8, but the problem is real.
> 
> It is also not hard to see that the source file and lineno info will get
> messed up, as the inserted instruction will appear to be where the ld8
> instruction is.
> 
> I think we need to copy the entire CURR_SLOT structure when inserting an
> instruction.  I don't know offhand if this is safe though, and there is
> no easy way to test it.  I suspect we just need to try it and see if
> anything breaks.

Like this?


H.J.
2004-05-27  H.J. Lu  <hongjiu.lu@intel.com>

	* config/tc-ia64.c (remove_marked_resource): Restore the old
	slot when inserting srlz.i/srlz.d.

--- gas/config/tc-ia64.c.auto	2004-05-27 22:08:52.048307750 -0700
+++ gas/config/tc-ia64.c	2004-05-27 22:15:11.357126785 -0700
@@ -9560,8 +9560,7 @@ remove_marked_resource (rs)
 	insn_group_break (1, 0, 0);
       if (rs->insn_srlz < STATE_SRLZ)
 	{
-	  int oldqp = CURR_SLOT.qp_regno;
-	  struct ia64_opcode *oldidesc = CURR_SLOT.idesc;
+	  struct slot oldslot = CURR_SLOT;
 	  /* Manually jam a srlz.i insn into the stream */
 	  CURR_SLOT.qp_regno = 0;
 	  CURR_SLOT.idesc = ia64_find_opcode ("srlz.i");
@@ -9569,8 +9568,7 @@ remove_marked_resource (rs)
 	  md.curr_slot = (md.curr_slot + 1) % NUM_SLOTS;
 	  if (++md.num_slots_in_use >= NUM_SLOTS)
 	    emit_one_bundle ();
-	  CURR_SLOT.qp_regno = oldqp;
-	  CURR_SLOT.idesc = oldidesc;
+	  CURR_SLOT = oldslot;
 	}
       insn_group_break (1, 0, 0);
       break;
@@ -9583,8 +9581,7 @@ remove_marked_resource (rs)
       if (rs->data_srlz < STATE_STOP)
 	insn_group_break (1, 0, 0);
       {
-	int oldqp = CURR_SLOT.qp_regno;
-	struct ia64_opcode *oldidesc = CURR_SLOT.idesc;
+	struct slot oldslot = CURR_SLOT;
 	/* Manually jam a srlz.d insn into the stream */
 	CURR_SLOT.qp_regno = 0;
 	CURR_SLOT.idesc = ia64_find_opcode ("srlz.d");
@@ -9592,8 +9589,7 @@ remove_marked_resource (rs)
 	md.curr_slot = (md.curr_slot + 1) % NUM_SLOTS;
 	if (++md.num_slots_in_use >= NUM_SLOTS)
 	  emit_one_bundle ();
-	CURR_SLOT.qp_regno = oldqp;
-	CURR_SLOT.idesc = oldidesc;
+	CURR_SLOT = oldslot;
       }
       break;
     case IA64_DVS_IMPLIED:



More information about the Binutils mailing list