This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix -fmudflap ICE with setjmp (PR middle-end/35314)
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: "Jakub Jelinek" <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 9 Nov 2008 17:32:07 -0600
- Subject: Re: [PATCH] Fix -fmudflap ICE with setjmp (PR middle-end/35314)
- References: <20081108203435.GO3572@tyan-ft48-01.lab.bos.redhat.com>
On Sat, Nov 8, 2008 at 2:34 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> is_ctrl_altering_stmt has:
> /* A non-pure/const call alters flow control if the current
> function has nonlocal labels. */
> if (!(flags & (ECF_CONST | ECF_PURE))
> && cfun->has_nonlocal_label)
> return true;
> When mudflap2 adds __mf_check () call in a function which
> has_nonlocal_label and adds some further statements after it, verification
> fails because of this. This patch splits the bb after __mf_check () call
> in that case to make verification happy (eventhough __mf_check won't longjmp to
> any of the nonlocal labels, is_ctrl_altering_stmt doesn't know that).
>
> Ok for trunk?
Ok.
Thanks,
Richard.
> 2008-11-08 Jakub Jelinek <jakub@redhat.com>
>
> PR middle-end/35314
> * tree-mudflap.c (mf_build_check_statement_for): Split then_block
> after __mf_check call if the call must end a bb.
>
> * testsuite/libmudflap.c/pass67-frag.c: New test.
>
> --- gcc/tree-mudflap.c.jj 2008-10-23 13:21:41.000000000 +0200
> +++ gcc/tree-mudflap.c 2008-11-08 20:41:27.000000000 +0100
> @@ -669,6 +669,15 @@ mf_build_check_statement_for (tree base,
>
> if (! flag_mudflap_threads)
> {
> + if (stmt_ends_bb_p (g))
> + {
> + gsi = gsi_start_bb (then_bb);
> + gsi_insert_seq_after (&gsi, seq, GSI_CONTINUE_LINKING);
> + e = split_block (then_bb, g);
> + then_bb = e->dest;
> + seq = gimple_seq_alloc ();
> + }
> +
> g = gimple_build_assign (mf_cache_shift_decl_l, mf_cache_shift_decl);
> gimple_seq_add_stmt (&seq, g);
>
> --- libmudflap/testsuite/libmudflap.c/pass67-frag.c.jj 2008-11-08 20:48:49.000000000 +0100
> +++ libmudflap/testsuite/libmudflap.c/pass67-frag.c 2008-11-08 20:48:14.000000000 +0100
> @@ -0,0 +1,14 @@
> +/* PR middle-end/35314 */
> +/* { dg-do compile } */
> +/* { dg-options "-fmudflap" } */
> +
> +#include <setjmp.h>
> +
> +jmp_buf buf;
> +
> +void
> +foo (volatile char *p)
> +{
> + if (__builtin_setjmp (buf))
> + *p;
> +}
>
> Jakub
>