This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
re: [dataflow][RFC] Fix mode-switching for MODE_ENTRY/EXIT target
- From: Kenneth Zadeck <Kenneth dot Zadeck at NaturalBridge dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: kkojima at gcc dot gnu dot org
- Date: Fri, 02 Feb 2007 22:45:05 -0500
- Subject: re: [dataflow][RFC] Fix mode-switching for MODE_ENTRY/EXIT target
- References: <20070130.084957.68152606.kkojima@rr.iij4u.or.jp>
- Reply-to: Kenneth dot Zadeck at NaturalBridge dot com
Kaz
This is fine for the dataflow branch.
Kenny
> This is against mode-switching.c but would be actually SH specific.
> In mode-switching.c/optimize_mode_switching, split_edge and
> create_pre_exit might make new blocks after df_analyze is already done.
> It causes a segfault:
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x08530503 in rest_of_handle_mode_switching ()
> at ../../TMP/dataflow/gcc/mode-switching.c:463
> 463 REG_SET_TO_HARD_REG_SET (live_now, DF_LIVE_IN (bb));
>
> The attached patch moves df_analyze after split_edge and create_pre_exit.
> This change will affect the SH target only because these split_edge and
> create_pre_exit are guarded with MODE_ENTRY/EXIT macros which are defined
> only by SH now. The first hunk of the patch is to tweak create_pre_exit
> for -O0. When runnning C testsuite for SH, I see ICEs with
>
> internal compiler error: in create_pre_exit, at mode-switching.c:352
>
> It seems that the rtl (clobber (reg [<result>])) was optimized away
> with the trunk compiler even at -O0 but isn't optimized away with
> the dataflow-branch compiler at -O0. The attached patch is to handle
> this. Again it'll affect SH only because create_pre_exit is called
> by SH backend only.
> Bootstrapped and regtested on i686-pc-linux-gnu and sh4-unknown-linux-gnu
> with no new failures.
>
> Regards,
> kaz
> --
> * mode-switching.c (create_pre_exit): Skip CLOBBER of pseudo
> register for the result when not optimizing.
> (optimize_mode_switching): Move df_ri_add_problem and df_analyze
> calls after create_pre_exit call.
>
> diff -uprN ORIG/dataflow/gcc/mode-switching.c LOCAL/dataflow/gcc/mode-switching.c
> --- ORIG/dataflow/gcc/mode-switching.c 2007-01-24 09:06:41.000000000 +0900
> +++ LOCAL/dataflow/gcc/mode-switching.c 2007-01-26 20:56:58.000000000 +0900
> @@ -1,5 +1,5 @@
> /* CPU mode switching
> - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
> + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
> Free Software Foundation, Inc.
>
> This file is part of GCC.
> @@ -268,6 +268,25 @@ create_pre_exit (int n_entities, int *en
> return_copy_pat = PATTERN (return_copy);
> if (GET_CODE (return_copy_pat) != CLOBBER)
> break;
> + else if (!optimize)
> + {
> + /* This might be (clobber (reg [<result>]))
> + when not optimizing. Then check if
> + the previous insn is the clobber for
> + the return register. */
> + copy_reg = SET_DEST (return_copy_pat);
> + if (GET_CODE (copy_reg) == REG
> + && !HARD_REGISTER_NUM_P (REGNO (copy_reg)))
> + {
> + if (INSN_P (PREV_INSN (return_copy)))
> + {
> + return_copy = PREV_INSN (return_copy);
> + return_copy_pat = PATTERN (return_copy);
> + if (GET_CODE (return_copy_pat) != CLOBBER)
> + break;
> + }
> + }
> + }
> }
> copy_reg = SET_DEST (return_copy_pat);
> if (GET_CODE (copy_reg) == REG)
> @@ -420,9 +439,6 @@ optimize_mode_switching (void)
> if (! n_entities)
> return 0;
>
> - df_ri_add_problem (0);
> - df_analyze ();
> -
> #if defined (MODE_ENTRY) && defined (MODE_EXIT)
> /* Split the edge from the entry block, so that we can note that
> there NORMAL_MODE is supplied. */
> @@ -430,6 +446,9 @@ optimize_mode_switching (void)
> pre_exit = create_pre_exit (n_entities, entity_map, num_modes);
> #endif
>
> + df_ri_add_problem (0);
> + df_analyze ();
> +
> /* Create the bitmap vectors. */
>
> antic = sbitmap_vector_alloc (last_basic_block, n_entities);