ira_use_lra_p is a global variable use in ira as well as backend_init_target (). It's fine to be used in IRA as it's will be initialized at the beginning of ira pass.

However, early in backend_init_target (), this variable may not be initialized yet. There is a check in backend_init_target ():

if (!ira_use_lra_p)
  init_reload ();

In this case, init_reload () will always be called if ira_use_lra_p is not initialized.

ira_init_once () is a better place for the initialization.
It's called early in initialize_rtl (), just before
backend_init_target ().
And as the name suggests, it's called once to initialize function independent data structure.

aarch64-none-elf regression test Okay, x86-64-linux bootstrap Okay.



2016-09-21  Renlin Li  <renlin...@arm.com>

        * ira.c (ira): Move ira_use_lra_p initialization code to ...
        (ira_init_once): Here.
diff --git a/gcc/ira.c b/gcc/ira.c
index f8a59e3..9e7ba52 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -1665,6 +1665,8 @@ ira_init_once (void)
   ira_init_costs_once ();
   lra_init_once ();
+  ira_use_lra_p = targetm.lra_p ();
 /* Free ira_max_register_move_cost, ira_may_move_in_cost and
@@ -5082,7 +5084,6 @@ ira (FILE *f)
   ira_conflicts_p = optimize > 0;
-  ira_use_lra_p = targetm.lra_p ();
   /* If there are too many pseudos and/or basic blocks (e.g. 10K
      pseudos and 10K blocks or 100K pseudos and 1K blocks), we will
      use simplified and faster algorithms in LRA.  */

Reply via email to