> 
> This causes a segfault on gcc.target/mips/umips-store16-1.c.  The register
> asm:
> 
> register unsigned int global asm ("$16");
> 
> causes us to globalise $16 and call reinit_regs.  reinit_regs in turn
> calls ira_init, but IRA hasn't been initialised at this point and
> prerequisites like init_fake_stack_mems haven't yet been called.

Hmm, did not expected this path indeed...
> 
> Does the patch below look OK?
> Index: gcc/toplev.c
> ===================================================================
> --- gcc/toplev.c      2014-07-11 11:54:41.604838961 +0100
> +++ gcc/toplev.c      2014-07-16 08:22:36.226034738 +0100
> @@ -1604,6 +1604,10 @@ backend_init_target (void)
>       on a mode change.  */
>    init_expmed ();
>    init_lower_subreg ();
> +  init_set_costs ();
> +
> +  init_expr_target ();
> +  ira_init ();

ira_init is the most expensive part of our intialization, this change seems to 
make
it unconditoinal at astartup again that is somewhat unfortunate.  Perhaps there
is more sensible solution? Why probably do not need to reinit before rtl has
been initialized at first time?

Honza
>  
>    /* We may need to recompute regno_save_code[] and regno_restore_code[]
>       after a mode change as well.  */
> @@ -1682,7 +1686,8 @@ lang_dependent_init_target (void)
>       front end is initialized.  It also depends on the HAVE_xxx macros
>       generated from the target machine description.  */
>    init_optabs ();
> -  this_target_rtl->lang_dependent_initialized = false;
> +
> +  gcc_assert (!this_target_rtl->target_specific_initialized);
>  }
>  
>  /* Perform initializations that are lang-dependent or target-dependent.
> @@ -1701,26 +1706,10 @@ initialize_rtl (void)
>  
>    /* Target specific RTL backend initialization.  */
>    if (!this_target_rtl->target_specific_initialized)
> -    backend_init_target ();
> -  this_target_rtl->target_specific_initialized = true;
> -
> -  if (this_target_rtl->lang_dependent_initialized)
> -    return;
> -  this_target_rtl->lang_dependent_initialized = true;
> -
> -  /* The following initialization functions need to generate rtl, so
> -     provide a dummy function context for them.  */
> -  init_dummy_function_start ();
> -
> -  /* Do the target-specific parts of expr initialization.  */
> -  init_expr_target ();
> -
> -  /* Although the actions of these functions are language-independent,
> -     they use optabs, so we cannot call them from backend_init.  */
> -  init_set_costs ();
> -  ira_init ();
> -
> -  expand_dummy_function_end ();
> +    {
> +      backend_init_target ();
> +      this_target_rtl->target_specific_initialized = true;
> +    }
>  }
>  
>  /* Language-dependent initialization.  Returns nonzero on success.  */

Reply via email to