Patchwork Fix invalid asm goto error recovery (PR middle-end/52650)

login
register
mail settings
Submitter Jakub Jelinek
Date Nov. 27, 2012, 1:26 p.m.
Message ID <20121127132602.GZ2315@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/202216/
State New
Headers show

Comments

Jakub Jelinek - Nov. 27, 2012, 1:26 p.m.
Hi!

delete_insn_and_edges doesn't DTRT here, there is __builtin_unreachable
after the invalid inline asm goto.  Rather than changing the CFG and trying
to figure out what to do to remove the bogus asm goto successfully, it seems
much easier to just turn it into asm goto ("" : : : clobbers... : lab1...);
i.e. clear template and inputs.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2012-11-27  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/52650
	* function.c (instantiate_virtual_regs_in_insn): Don't delete invalid
	asm gotos, instead just clear their template and inputs.


	Jakub
Richard Guenther - Nov. 27, 2012, 1:30 p.m.
On Tue, Nov 27, 2012 at 2:26 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> delete_insn_and_edges doesn't DTRT here, there is __builtin_unreachable
> after the invalid inline asm goto.  Rather than changing the CFG and trying
> to figure out what to do to remove the bogus asm goto successfully, it seems
> much easier to just turn it into asm goto ("" : : : clobbers... : lab1...);
> i.e. clear template and inputs.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2012-11-27  Jakub Jelinek  <jakub@redhat.com>
>
>         PR middle-end/52650
>         * function.c (instantiate_virtual_regs_in_insn): Don't delete invalid
>         asm gotos, instead just clear their template and inputs.
>
> --- gcc/function.c.jj   2012-11-21 16:00:12.000000000 +0100
> +++ gcc/function.c      2012-11-26 16:47:24.907472155 +0100
> @@ -1738,7 +1738,18 @@ instantiate_virtual_regs_in_insn (rtx in
>        if (!check_asm_operands (PATTERN (insn)))
>         {
>           error_for_asm (insn, "impossible constraint in %<asm%>");
> -         delete_insn_and_edges (insn);
> +         /* For asm goto, instead of fixing up all the edges
> +            just clear the template and clear input operands
> +            (asm goto doesn't have any output operands).  */
> +         if (JUMP_P (insn))
> +           {
> +             rtx asm_op = extract_asm_operands (PATTERN (insn));
> +             ASM_OPERANDS_TEMPLATE (asm_op) = ggc_strdup ("");
> +             ASM_OPERANDS_INPUT_VEC (asm_op) = rtvec_alloc (0);
> +             ASM_OPERANDS_INPUT_CONSTRAINT_VEC (asm_op) = rtvec_alloc (0);
> +           }
> +         else
> +           delete_insn (insn);
>         }
>      }
>    else
>
>         Jakub

Patch

--- gcc/function.c.jj	2012-11-21 16:00:12.000000000 +0100
+++ gcc/function.c	2012-11-26 16:47:24.907472155 +0100
@@ -1738,7 +1738,18 @@  instantiate_virtual_regs_in_insn (rtx in
       if (!check_asm_operands (PATTERN (insn)))
 	{
 	  error_for_asm (insn, "impossible constraint in %<asm%>");
-	  delete_insn_and_edges (insn);
+	  /* For asm goto, instead of fixing up all the edges
+	     just clear the template and clear input operands
+	     (asm goto doesn't have any output operands).  */
+	  if (JUMP_P (insn))
+	    {
+	      rtx asm_op = extract_asm_operands (PATTERN (insn));
+	      ASM_OPERANDS_TEMPLATE (asm_op) = ggc_strdup ("");
+	      ASM_OPERANDS_INPUT_VEC (asm_op) = rtvec_alloc (0);
+	      ASM_OPERANDS_INPUT_CONSTRAINT_VEC (asm_op) = rtvec_alloc (0);
+	    }
+	  else
+	    delete_insn (insn);
 	}
     }
   else