re PR target/30848 (ICE with invalid constraint in asm statement)
authorRichard Henderson <rth@redhat.com>
Wed, 7 Mar 2007 18:13:29 +0000 (10:13 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Wed, 7 Mar 2007 18:13:29 +0000 (10:13 -0800)
        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.

From-SVN: r122669

gcc/ChangeLog
gcc/reg-stack.c
gcc/testsuite/gcc.target/i386/pr30848.c [new file with mode: 0644]

index 4f61c94..8712524 100644 (file)
@@ -1,3 +1,9 @@
+2007-03-07  Richard Henderson  <rth@redhat.com>
+
+       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.
+
 2007-03-07  Paul Brook  <paul@codesourcery.com>
 
        * config/arm/libunwind.S: Add .arch/.object_arch for armv4 builds.
index e6802b1..8413ca3 100644 (file)
@@ -815,9 +815,19 @@ emit_swap_insn (rtx insn, stack regstack, rtx reg)
 
   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);
 
diff --git a/gcc/testsuite/gcc.target/i386/pr30848.c b/gcc/testsuite/gcc.target/i386/pr30848.c
new file mode 100644 (file)
index 0000000..2a92851
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+
+void foo(double d)
+{
+  __asm__ ("" : "=u" (d));  /* { dg-error "output regs" } */
+}