fix target/30848

Richard Henderson rth@redhat.com
Wed Mar 7 18:34:00 GMT 2007


Tested x86_64.  I intend to apply to the 4.1 and 4.2 branches
as soon as testing there is complete.


r~



        PR target/30848
        * reg-stack.c (emit_swap_insn): If a malformed asm was seen,
        silently fix up the stack in the case of a missing register.

--- reg-stack.c	(revision 122675)
+++ reg-stack.c	(local)
@@ -815,9 +815,19 @@ emit_swap_insn (rtx insn, stack regstack
 
   hard_regno = get_hard_regnum (regstack, reg);
 
-  gcc_assert (hard_regno >= FIRST_STACK_REG);
   if (hard_regno == FIRST_STACK_REG)
     return;
+  if (hard_regno == -1)
+    {
+      /* Something failed if the register wasn't on the stack.  If we had
+	 malformed asms, we zapped the instruction itself, but that didn't
+	 produce the same pattern of register sets as before.  To prevent
+	 further failure, adjust REGSTACK to include REG at TOP.  */
+      gcc_assert (any_malformed_asm);
+      regstack->reg[++regstack->top] = REGNO (reg);
+      return;
+    }
+  gcc_assert (hard_regno >= FIRST_STACK_REG);
 
   other_reg = regstack->top - (hard_regno - FIRST_STACK_REG);
 
--- testsuite/gcc.target/i386/pr30848.c	(revision 122675)
+++ testsuite/gcc.target/i386/pr30848.c	(local)
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+
+void foo(double d)
+{
+  __asm__ ("" : "=u" (d));  /* { dg-error "output regs" } */
+}



More information about the Gcc-patches mailing list