passes.c (execute_one_pass): Do not apply all transforms prior every simple IPA pass.
authorJan Hubicka <hubicka@ucw.cz>
Sun, 16 Nov 2014 19:36:37 +0000 (20:36 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sun, 16 Nov 2014 19:36:37 +0000 (19:36 +0000)
* passes.c (execute_one_pass): Do not apply all transforms prior
every simple IPA pass.
* cgraphunit.c: Do not include fibheap.h
(expand_thunk): Use get_untransformed_body.
(cgraph_node::expand): Likewise.
* tree-ssa-structalias.c (ipa_pta_execute): Skip inline clones.
* cgraph.c (release_function_body): Do not push cfun when CFG is not there.
(cgraph_node::get_untransformed_body): Break out from ...
(cgraph_node::get_body): ... here; add code to apply all transforms.
* cgraph.h (cgraph_node): Add get_untransformed_body.
* ipa-icf.c (sem_function::init): Use get_untransformed_body.
* cgraphclones.c (duplicate_thunk_for_node): Likewise.
* tree-inline.c (expand_call_inline): LIkewise.
* i386.c (ix86_reset_to_default_globals): Break out from ...
(ix86_set_current_function): ... here;
(ix86_reset_previous_fndecl): Use it.
(ix86_simd_clone_adjust): Use ix86_reset_previous_fndecl.

From-SVN: r217633

gcc/ChangeLog
gcc/cgraph.c
gcc/cgraph.h
gcc/cgraphclones.c
gcc/cgraphunit.c
gcc/config/i386/i386.c
gcc/ipa-icf.c
gcc/passes.c
gcc/tree-inline.c
gcc/tree-ssa-structalias.c

index 69bed229701cb5ac6d918471644253c61dccf289..d035fe15e2012cce44eaac6afd2c4c22da5017d9 100644 (file)
@@ -1,3 +1,23 @@
+2014-11-16  Jan Hubicka  <hubicka@ucw.cz>
+
+       * passes.c (execute_one_pass): Do not apply all transforms prior
+       every simple IPA pass.
+       * cgraphunit.c: Do not include fibheap.h
+       (expand_thunk): Use get_untransformed_body.
+       (cgraph_node::expand): Likewise.
+       * tree-ssa-structalias.c (ipa_pta_execute): Skip inline clones.
+       * cgraph.c (release_function_body): Do not push cfun when CFG is not there.
+       (cgraph_node::get_untransformed_body): Break out from ...
+       (cgraph_node::get_body): ... here; add code to apply all transforms.
+       * cgraph.h (cgraph_node): Add get_untransformed_body.
+       * ipa-icf.c (sem_function::init): Use get_untransformed_body.
+       * cgraphclones.c (duplicate_thunk_for_node): Likewise.
+       * tree-inline.c (expand_call_inline): LIkewise.
+       * i386.c (ix86_reset_to_default_globals): Break out from ...
+       (ix86_set_current_function): ... here;
+       (ix86_reset_previous_fndecl): Use it.
+       (ix86_simd_clone_adjust): Use ix86_reset_previous_fndecl.
+
 2014-11-16  Eric Botcazou  <ebotcazou@adacore.com>
 
        * doc/tm.texi.in (TARGET_FLAGS_REGNUM): Move around.
index a66c9c0ea75dcb4eac0d792bb12a82e29431f084..ad181b062c858f189c886b8c37a7e3cb08b6c77e 100644 (file)
@@ -1664,29 +1664,33 @@ release_function_body (tree decl)
 {
   if (DECL_STRUCT_FUNCTION (decl))
     {
-      push_cfun (DECL_STRUCT_FUNCTION (decl));
-      if (cfun->cfg
-         && current_loops)
-       {
-         cfun->curr_properties &= ~PROP_loops;
-         loop_optimizer_finalize ();
-       }
-      if (cfun->gimple_df)
+      if (DECL_STRUCT_FUNCTION (decl)->cfg
+         || DECL_STRUCT_FUNCTION (decl)->gimple_df)
        {
-         delete_tree_ssa ();
-         delete_tree_cfg_annotations ();
-         cfun->eh = NULL;
-       }
-      if (cfun->cfg)
-       {
-         gcc_assert (!dom_info_available_p (CDI_DOMINATORS));
-         gcc_assert (!dom_info_available_p (CDI_POST_DOMINATORS));
-         clear_edges ();
-         cfun->cfg = NULL;
+         push_cfun (DECL_STRUCT_FUNCTION (decl));
+         if (cfun->cfg
+             && current_loops)
+           {
+             cfun->curr_properties &= ~PROP_loops;
+             loop_optimizer_finalize ();
+           }
+         if (cfun->gimple_df)
+           {
+             delete_tree_ssa ();
+             delete_tree_cfg_annotations ();
+             cfun->eh = NULL;
+           }
+         if (cfun->cfg)
+           {
+             gcc_assert (!dom_info_available_p (CDI_DOMINATORS));
+             gcc_assert (!dom_info_available_p (CDI_POST_DOMINATORS));
+             clear_edges ();
+             cfun->cfg = NULL;
+           }
+         if (cfun->value_histograms)
+           free_histograms ();
+         pop_cfun ();
        }
-      if (cfun->value_histograms)
-       free_histograms ();
-      pop_cfun ();
       gimple_set_body (decl, NULL);
       /* Struct function hangs a lot of data that would leak if we didn't
          removed all pointers to it.   */
@@ -3138,7 +3142,7 @@ cgraph_node::function_symbol (enum availability *availability)
    present.  */
 
 bool
-cgraph_node::get_body (void)
+cgraph_node::get_untransformed_body (void)
 {
   lto_file_decl_data *file_data;
   const char *data, *name;
@@ -3178,6 +3182,44 @@ cgraph_node::get_body (void)
   return true;
 }
 
+/* Prepare function body.  When doing LTO, read cgraph_node's body from disk 
+   if it is not already present.  When some IPA transformations are scheduled,
+   apply them.  */
+
+bool
+cgraph_node::get_body (void)
+{
+  bool updated;
+
+  updated = get_untransformed_body ();
+
+  /* Getting transformed body makes no sense for inline clones;
+     we should never use this on real clones becuase they are materialized
+     early.
+     TODO: Materializing clones here will likely lead to smaller LTRANS
+     footprint. */
+  gcc_assert (!global.inlined_to && !clone_of);
+  if (ipa_transforms_to_apply.exists ())
+    {
+      opt_pass *saved_current_pass = current_pass;
+      FILE *saved_dump_file = dump_file;
+      int saved_dump_flags = dump_flags;
+
+      push_cfun (DECL_STRUCT_FUNCTION (decl));
+      execute_all_ipa_transforms ();
+      cgraph_edge::rebuild_edges ();
+      free_dominance_info (CDI_DOMINATORS);
+      free_dominance_info (CDI_POST_DOMINATORS);
+      pop_cfun ();
+      updated = true;
+
+      current_pass = saved_current_pass;
+      dump_file = saved_dump_file;
+      dump_flags = saved_dump_flags;
+    }
+  return updated;
+}
+
 /* Return the DECL_STRUCT_FUNCTION of the function.  */
 
 struct function *
index 5d949abc722b00b2c6956dd74700471a462ed353..77c2a6058e768ff1c782ec532ac3507d509b1770 100644 (file)
@@ -933,6 +933,11 @@ public:
 
   /* When doing LTO, read cgraph_node's body from disk if it is not already
      present.  */
+  bool get_untransformed_body (void);
+
+  /* Prepare function body.  When doing LTO, read cgraph_node's body from disk 
+     if it is not already present.  When some IPA transformations are scheduled,
+     apply them.  */
   bool get_body (void);
 
   /* Release memory used to represent body of function.
index c8892daf52d41896b6fd762dcfc2f667f51045c1..7dc96f1d5ba8e1b613e418048fa1e6713b7b0cca 100644 (file)
@@ -307,7 +307,7 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node *node)
     node = duplicate_thunk_for_node (thunk_of, node);
 
   if (!DECL_ARGUMENTS (thunk->decl))
-    thunk->get_body ();
+    thunk->get_untransformed_body ();
 
   cgraph_edge *cs;
   for (cs = node->callers; cs; cs = cs->next_caller)
@@ -1067,7 +1067,7 @@ symbol_table::materialize_all_clones (void)
              && !gimple_has_body_p (node->decl))
            {
              if (!node->clone_of->clone_of)
-               node->clone_of->get_body ();
+               node->clone_of->get_untransformed_body ();
              if (gimple_has_body_p (node->clone_of->decl))
                {
                  if (symtab->dump_file)
index 534c61301d02ccb46f233fa5add78c191774a334..4fba9ff59ce4bccc2bd420121057d26b47589c52 100644 (file)
@@ -197,7 +197,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "target.h"
 #include "diagnostic.h"
 #include "params.h"
-#include "fibheap.h"
 #include "intl.h"
 #include "hash-map.h"
 #include "plugin-api.h"
@@ -1469,7 +1468,7 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
        }
 
       if (in_lto_p)
-       get_body ();
+       get_untransformed_body ();
       a = DECL_ARGUMENTS (thunk_fndecl);
       
       current_function_decl = thunk_fndecl;
@@ -1522,7 +1521,7 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
       gimple ret;
 
       if (in_lto_p)
-       get_body ();
+       get_untransformed_body ();
       a = DECL_ARGUMENTS (thunk_fndecl);
 
       current_function_decl = thunk_fndecl;
@@ -1744,7 +1743,7 @@ cgraph_node::expand (void)
   announce_function (decl);
   process = 0;
   gcc_assert (lowered);
-  get_body ();
+  get_untransformed_body ();
 
   /* Generate RTL for the body of DECL.  */
 
index 3400ca3d5771f7ce6e9ef6e235c25ecdbc5e1674..7942cec4595dbdaa85e674ef64c23eff81f782bb 100644 (file)
@@ -5029,10 +5029,35 @@ ix86_can_inline_p (tree caller, tree callee)
 /* Remember the last target of ix86_set_current_function.  */
 static GTY(()) tree ix86_previous_fndecl;
 
+/* Set target globals to default.  */
+
+static void
+ix86_reset_to_default_globals (void)
+{
+  tree old_tree = (ix86_previous_fndecl
+                  ? DECL_FUNCTION_SPECIFIC_TARGET (ix86_previous_fndecl)
+                  : NULL_TREE);
+
+  if (old_tree)
+    {
+      tree new_tree = target_option_current_node;
+      cl_target_option_restore (&global_options,
+                               TREE_TARGET_OPTION (new_tree));
+      if (TREE_TARGET_GLOBALS (new_tree))
+       restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
+      else if (new_tree == target_option_default_node)
+       restore_target_globals (&default_target_globals);
+      else
+       TREE_TARGET_GLOBALS (new_tree)
+         = save_target_globals_default_opts ();
+    }
+}
+
 /* Invalidate ix86_previous_fndecl cache.  */
 void
 ix86_reset_previous_fndecl (void)
 {
+  ix86_reset_to_default_globals ();
   ix86_previous_fndecl = NULL_TREE;
 }
 
@@ -5055,7 +5080,6 @@ ix86_set_current_function (tree fndecl)
                       ? DECL_FUNCTION_SPECIFIC_TARGET (fndecl)
                       : NULL_TREE);
 
-      ix86_previous_fndecl = fndecl;
       if (old_tree == new_tree)
        ;
 
@@ -5071,18 +5095,8 @@ ix86_set_current_function (tree fndecl)
        }
 
       else if (old_tree)
-       {
-         new_tree = target_option_current_node;
-         cl_target_option_restore (&global_options,
-                                   TREE_TARGET_OPTION (new_tree));
-         if (TREE_TARGET_GLOBALS (new_tree))
-           restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
-         else if (new_tree == target_option_default_node)
-           restore_target_globals (&default_target_globals);
-         else
-           TREE_TARGET_GLOBALS (new_tree)
-             = save_target_globals_default_opts ();
-       }
+       ix86_reset_to_default_globals ();
+      ix86_previous_fndecl = fndecl;
     }
 }
 
@@ -50972,7 +50986,7 @@ ix86_simd_clone_adjust (struct cgraph_node *node)
   bool ok = ix86_valid_target_attribute_p (node->decl, NULL, args, 0);
   gcc_assert (ok);
   pop_cfun ();
-  ix86_previous_fndecl = NULL_TREE;
+  ix86_reset_previous_fndecl ();
   ix86_set_current_function (node->decl);
 }
 
index 92ec82d7c8a9b428a87f6bd7a5a282e96621dabd..2d5fcf56b425e9477e7440375935e386a48a6d70 100644 (file)
@@ -706,7 +706,7 @@ void
 sem_function::init (void)
 {
   if (in_lto_p)
-    get_node ()->get_body ();
+    get_node ()->get_untransformed_body ();
 
   tree fndecl = node->decl;
   function *func = DECL_STRUCT_FUNCTION (fndecl);
index aa40fe5fa30caa18c25ab7d6c199aa8be327b9ee..c818d8ad9191650d15e304c801ccf2e23c568c10 100644 (file)
@@ -2214,36 +2214,6 @@ execute_one_pass (opt_pass *pass)
      executed.  */
   invoke_plugin_callbacks (PLUGIN_PASS_EXECUTION, pass);
 
-  /* SIPLE IPA passes do not handle callgraphs with IPA transforms in it.
-     Apply all trnasforms first.  */
-  if (pass->type == SIMPLE_IPA_PASS)
-    {
-      struct cgraph_node *node;
-      bool applied = false;
-      FOR_EACH_DEFINED_FUNCTION (node)
-       if (node->analyzed
-           && node->has_gimple_body_p ()
-           && (!node->clone_of || node->decl != node->clone_of->decl))
-         {
-           if (!node->global.inlined_to
-               && node->ipa_transforms_to_apply.exists ())
-             {
-               node->get_body ();
-               push_cfun (DECL_STRUCT_FUNCTION (node->decl));
-               execute_all_ipa_transforms ();
-               cgraph_edge::rebuild_edges ();
-               free_dominance_info (CDI_DOMINATORS);
-               free_dominance_info (CDI_POST_DOMINATORS);
-               pop_cfun ();
-               applied = true;
-             }
-         }
-      if (applied)
-       symtab->remove_unreachable_nodes (false, dump_file);
-      /* Restore current_pass.  */
-      current_pass = pass;
-    }
-
   if (!quiet_flag && !cfun)
     fprintf (stderr, " <%s>", pass->name ? pass->name : "");
 
index 520546e3d09bf45ca3f4eb507e1053fdda5ca226..510b53ee41654c069e579d5a029b27b1d0541fe7 100644 (file)
@@ -4338,7 +4338,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id)
       goto egress;
     }
   fn = cg_edge->callee->decl;
-  cg_edge->callee->get_body ();
+  cg_edge->callee->get_untransformed_body ();
 
 #ifdef ENABLE_CHECKING
   if (cg_edge->callee->decl != id->dst_node->decl)
index 36213772f4cb19f5d90a6bb5755f45e76a13b78b..7157693e5d019b0c17725318631259c1ef74331c 100644 (file)
@@ -7086,7 +7086,7 @@ ipa_pta_execute (void)
       /* Nodes without a body are not interesting.  Especially do not
          visit clones at this point for now - we get duplicate decls
         there for inline clones at least.  */
-      if (!node->has_gimple_body_p () || node->clone_of)
+      if (!node->has_gimple_body_p () || node->global.inlined_to)
        continue;
       node->get_body ();