reg-stack.c problem

H.J. Lu hjl@lucon.org
Mon Apr 20 13:06:00 GMT 1998


>   > Basically convert_regs () calls change_stack () with INSN to emit
>   > some insn after INSN. But some insn has been added after INSN so
>   > that change_stack () will emit some insn at the wrong place. As the
>   > result, the floating point is broken on x86.
> This is an extremely confusing explanation, primarily because you
> use "insn"/INSN to refer to three different things.
> 
> Basically is sounds like you have
> 
> 	insn 1
>         insn 2
> 
> 
> It sounds like we thought we wanted to insert after insn 1, but
> because of other reg-stack actions we really wanted to insert
> after insn 2.
> 
>   > This patch seems to fix it. Could someone please take a look? Given
>   > the bugs we have seen in egcs 1.0.2, I suggest egcs 1.0.3 be made.
> I must confess I don't undersatnd reg-stack all that well.  Assuming
> your analysis and explanation are correct, then I think your change
> is OK, though possibly incomplete.
> 
> In particular I worry that we need to pass "new" instead of "insn"
> to the call to emit_pop_insn near the end of convert_regs.  I think
> the call to goto_block_pat in convert_regs is OK.

You may be right.

> 
> I also worry that there may be cases were we need to insert after
> insn 1 instead of after insn 2.  But I don't know reg-stack well
> enough to know if that can actually happen.

I don't think that should happen.

> 
> You might ask Bernd Schmidt or Stan Cox to look at the change and
> comment.
> 
> I'm going to go ahead and hesitantly install the change, but further
> comments from folks that understand this code would be greatly
> appreciated.
> 

How does this patch against egcs 1.0 in CVS sound?

Thanks.

-- 
H.J. Lu (hjl@gnu.org)
--
Mon Apr 20 08:02:56 1998  H.J. Lu  (hjl@gnu.org)

	(convert_regs): Abort if the last newly created insn is a JUMP
	insn.
	Call goto_block_pat (), emit_pop_insn () and straighten_stack ()
	with NEW instead of INSN.

--- reg-stack.c.1	Sat Apr 18 18:23:12 1998
+++ reg-stack.c	Mon Apr 20 08:01:58 1998
@@ -3108,6 +3108,9 @@ convert_regs ()
 
 	} while (insn != block_end[block]);
 
+      if (new != insn && GET_CODE (new) == JUMP_INSN)
+	abort ();
+
       /* Something failed if the stack life doesn't match.  */
 
       GO_IF_HARD_REG_EQUAL (regstack.reg_set, block_out_reg_set[block], win);
@@ -3121,8 +3124,8 @@ convert_regs ()
 	 jump target if the target block's stack order hasn't been set
 	 yet.  */
 
-      if (GET_CODE (insn) == JUMP_INSN)
-	goto_block_pat (insn, &regstack, PATTERN (insn));
+      if (GET_CODE (new) == JUMP_INSN)
+	goto_block_pat (new, &regstack, PATTERN (insn));
 
       /* Likewise handle the case where we fall into the next block.  */
 
@@ -3151,11 +3154,11 @@ convert_regs ()
      for (reg = regstack.top; reg >= 0; reg--)
         if (regstack.reg[reg] < value_reg_low
 	    || regstack.reg[reg] > value_reg_high)
-           insn = emit_pop_insn (insn, &regstack,
+           insn = emit_pop_insn (new, &regstack,
 			    FP_MODE_REG (regstack.reg[reg], DFmode),
 			    emit_insn_after);
    }
-  straighten_stack (insn, &regstack);
+  straighten_stack (new, &regstack);
 }
 
 /* Check expression PAT, which is in INSN, for label references.  if



More information about the Gcc mailing list