This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[lto] remove rebuild_ssa_for_lto


This patch forges ahead with the plan I suggested Friday to remove the
current full rebuilding of SSA we do.  The only changes from the patch
posted Friday are removing the early_lto_passes from the pass manager
along with the deletion of their associated code and finding yet another
tree flag that we need to serialize.

The remaining failures fall into the following non-exhaustive
categorization:

- Not supporting nested functions;
- Not supporting flexible arrays;
- Not supporting weird user-defined types (complex char);
- Problems with aliasing (maybe? -- 20020619-1.c);
- Problems with bitfields (e.g. 20040629-1.c);

Stats from just the -O2 -flto tests from execute.exp look like:

		=== gcc Summary ===

# of expected passes		1838
# of unexpected failures	51
# of unresolved testcases	31

As for SPECint2000, we can compile and run 181.mcf, 186.crafty,
197.parser, and 256.bzip2.  164.gzip and 175.vpr compile, but fail for
reasons I have not yet investigated.  As for the remaining C benchmarks:

- 176.gcc asserts in dwarf2out.c;
- 253.perlbmk apparently redeclares things incompatibly;
- 254.gap does the same;
- 255.vortex dies with corrupt LTO information;
- 300.twolf has mismatching declarations somewhere.

So we're doing better.

Committed to the LTO branch.

-Nathan

gcc/
	* tree-into-ssa.c (rebuild_ssa_for_lto): Remove.
	(pass_rebuild_ssa_for_lto): Remove.
	* tree-optimize.c (gate_early_lto_passes): Remove.
	(pass_early_lto_passes): Remove.
	* passes.c (init_optimization_passes): Remove pass_early_lto_passes
	and its sub-passes.
	* tree-pass.h (pass_early_lto_passes, pass_rebuild_ssa_for_lto):
	Remove.
	* lto-tree-flags.def (VAR_DECL): Add volatile_flag.

gcc/lto/
	* lto.c (lto_read_variable_formal_parameter_constant_DIE): Set
	TREE_THIS_VOLATILE if the associated type is a volatile type.
	(lto_materialize_function): Remove call to init_ssa_operands.
	* lto-read.c (input_expr_operand): Add SSA_NAME_VAR as a referenced
	variable when reading an SSA_NAME.  Do the same when reading a
	RESULT_DECL, a RETURN_EXPR, or an MTAG.
	(input_cfg): Call init_ssa_operands.
	(input_ssa_names): Set the default def of an SSA_NAME if necessary.
	Move call to init_tree_ssa...
	(lto_read_body): ...here.  Use push_cfun and pop_cfun.  Call
	add_referenced_var on any variables referenced from the body of the
	function.  Inform the rest of the compiler we are in SSA form and
	inform later passes about the current properties.

Index: gcc/tree-into-ssa.c
===================================================================
--- gcc/tree-into-ssa.c	(revision 130517)
+++ gcc/tree-into-ssa.c	(working copy)
@@ -3364,51 +3364,3 @@ done:
 
   timevar_pop (TV_TREE_SSA_INCREMENTAL);
 }
-
-
-static unsigned int
-rebuild_ssa_for_lto (void)
-{
-  block_stmt_iterator bsi;
-  basic_block bb;
-  referenced_var_iterator rvi;
-  tree var;
-
-  init_ssa_operands ();
-  FOR_EACH_BB (bb)
-    for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
-      update_stmt_if_modified (bsi_stmt (bsi));
-
-  FOR_EACH_REFERENCED_VAR (var, rvi)
-    {
-      if (dump_file)
-	print_node (dump_file, "\nmarking symbol for renaming ", var, 0);
-      mark_sym_for_renaming (var);
-    }
-
-  update_ssa (TODO_update_ssa);
-  return 1;
-
-}
-
-
-struct tree_opt_pass pass_rebuild_ssa_for_lto = 
-{
-  "rebuild_ssa",			/* name */
-  NULL,					/* gate */
-  rebuild_ssa_for_lto,			/* execute */
-  NULL,					/* sub */
-  NULL,					/* next */
-  0,					/* static_pass_number */
-  0,					/* tv_id */
-  PROP_cfg | PROP_referenced_vars,	/* properties_required */
-  PROP_ssa,				/* properties_provided */
-  0,					/* properties_destroyed */
-  0,					/* todo_flags_start */
-  TODO_dump_func
-    | TODO_verify_ssa
-    | TODO_remove_unused_locals,	/* todo_flags_finish */
-  0					/* letter */
-};
-
-
Index: gcc/tree-optimize.c
===================================================================
--- gcc/tree-optimize.c	(revision 130517)
+++ gcc/tree-optimize.c	(working copy)
@@ -139,35 +139,6 @@ struct tree_opt_pass pass_all_early_opti
   0					/* letter */
 };
 
-
-/* Control the early passes that are run if this is the lto front end.
-   This cannot be in the lto front end because that must be linked
-   separately.  */
-
-static bool
-gate_early_lto_passes (void)
-{
-	  /* Don't bother doing anything if the program has errors.  */
-  return (!errorcount && !sorrycount && in_lto_p);
-}
-
-struct tree_opt_pass pass_early_lto_passes =
-{
-  "early_lto_passes",    		/* name */
-  gate_early_lto_passes,		/* gate */
-  NULL,					/* execute */
-  NULL,					/* sub */
-  NULL,					/* next */
-  0,					/* static_pass_number */
-  0,					/* tv_id */
-  0,					/* properties_required */
-  0,					/* properties_provided */
-  0,					/* properties_destroyed */
-  0,					/* todo_flags_start */
-  0,		                        /* todo_flags_finish */
-  0					/* letter */
-};
-
 /* Pass: cleanup the CFG just before expanding trees to RTL.
    This is just a round of label cleanups and case node grouping
    because after the tree optimizers have run such cleanups may
Index: gcc/passes.c
===================================================================
--- gcc/passes.c	(revision 130517)
+++ gcc/passes.c	(working copy)
@@ -538,12 +538,6 @@ init_optimization_passes (void)
       NEXT_PASS (pass_rebuild_cgraph_edges);
       NEXT_PASS (pass_inline_parameters);
     }
-  NEXT_PASS (pass_early_lto_passes);
-    {
-      struct tree_opt_pass **p = &pass_early_lto_passes.sub;
-      NEXT_PASS (pass_referenced_vars);
-      NEXT_PASS (pass_rebuild_ssa_for_lto);
-    }
   NEXT_PASS (pass_ipa_lto_out);
   NEXT_PASS (pass_ipa_increase_alignment);
   NEXT_PASS (pass_ipa_matrix_reorg);
Index: gcc/tree-pass.h
===================================================================
--- gcc/tree-pass.h	(revision 130517)
+++ gcc/tree-pass.h	(working copy)
@@ -354,9 +354,6 @@ extern struct tree_opt_pass pass_free_da
 extern struct tree_opt_pass pass_init_datastructures;
 extern struct tree_opt_pass pass_fixup_cfg;
 
-extern struct tree_opt_pass pass_early_lto_passes;
-extern struct tree_opt_pass pass_rebuild_ssa_for_lto;
-
 extern struct tree_opt_pass pass_init_function;
 extern struct tree_opt_pass pass_jump;
 extern struct tree_opt_pass pass_rtl_eh;
Index: gcc/lto-tree-flags.def
===================================================================
--- gcc/lto-tree-flags.def	(revision 130545)
+++ gcc/lto-tree-flags.def	(working copy)
@@ -64,6 +64,7 @@
       ADD_CLASS_EXPR_FLAG (private_flag)
       ADD_CLASS_EXPR_FLAG (protected_flag)
       ADD_CLASS_EXPR_FLAG (side_effects_flag)
+      ADD_CLASS_EXPR_FLAG (volatile_flag)
       ADD_CLASS_EXPR_FLAG (readonly_flag)
       ADD_CLASS_EXPR_FLAG (constant_flag)
       ADD_CLASS_EXPR_FLAG (unsigned_flag)
Index: gcc/lto/lto.c
===================================================================
--- gcc/lto/lto.c	(revision 130545)
+++ gcc/lto/lto.c	(working copy)
@@ -2094,6 +2094,8 @@ lto_read_variable_formal_parameter_const
 
 	  if (TYPE_QUALS (type) & TYPE_QUAL_CONST)
 	    TREE_READONLY (decl) = 1;
+	  if (TYPE_QUALS (type) & TYPE_QUAL_VOLATILE)
+	    TREE_THIS_VOLATILE (decl) = 1;
 
 	  if (!TREE_PUBLIC (decl))
 	    {
@@ -2415,21 +2417,7 @@ lto_materialize_function (lto_info_fd *f
                             /*top_level=*/1,
                             /*at_end=*/0);
   if (body)
-    {
-      /* cgraph expects this to be called once for each function.  */
-      /* FIXME: eventually, reading LTO files should rebuild SSA
-	 perfectly so that things like the extra referenced_vars pass
-	 and rebuild_ssa_for_lto can go away.  Before that happens, this
-	 call needs to be moved earlier in the materialization
-	 process--probably to lto-read.c:input_cfg or before.  We could
-	 move it there now, but the current state means that we would do
-	 useless work while reading in LTO files--building SSA operands
-	 once while reading and then rebuilding again during
-	 rebuild_ssa_for_lto.  */
-      init_ssa_operands ();
-
-      cgraph_finalize_function (decl, /*nested=*/false);
-    }
+    cgraph_finalize_function (decl, /*nested=*/false);
 }
 
 static tree
Index: gcc/lto/lto-read.c
===================================================================
--- gcc/lto/lto-read.c	(revision 130517)
+++ gcc/lto/lto-read.c	(working copy)
@@ -735,6 +735,7 @@ input_expr_operand (struct input_block *
 
     case SSA_NAME:
       result = VEC_index (tree, SSANAMES (fn), input_uleb128 (ib));
+      add_referenced_var (SSA_NAME_VAR (result));
       break;
 
     case CONST_DECL:
@@ -834,6 +835,7 @@ input_expr_operand (struct input_block *
 
     case RESULT_DECL:
       result = build0 (code, type);
+      add_referenced_var (result);
       break;
 
     case COMPONENT_REF:
@@ -960,7 +962,10 @@ input_expr_operand (struct input_block *
             if (tag)
               op0 = input_expr_operand (ib, data_in, fn, tag);
             else
-              op0 = DECL_RESULT (current_function_decl);
+	      {
+		op0 = DECL_RESULT (current_function_decl);
+		add_referenced_var (op0);
+	      }
 
             result = build1 (code, type, op0);
 
@@ -1161,6 +1166,8 @@ input_expr_operand (struct input_block *
 
       recompute_tree_invariant_for_addr_expr (result);
     }
+  else if (MTAG_P (result))
+    add_referenced_var (result);
   return result;
 }
 
@@ -1430,6 +1437,7 @@ input_cfg (struct input_block *ib, struc
   int index;
 
   init_flow (fn);
+  init_ssa_operands ();
 
   LTO_DEBUG_TOKEN ("lastbb");
   bb_count = input_uleb128 (ib);
@@ -1565,7 +1573,6 @@ input_ssa_names (struct input_block *ib,
   unsigned int i;
   int size = input_uleb128 (ib);
 
-  init_tree_ssa (fn);
   init_ssanames (fn, size);
   i = input_uleb128 (ib);
 
@@ -1584,6 +1591,8 @@ input_ssa_names (struct input_block *ib,
 
       flags = input_tree_flags (ib, 0, true);
       process_tree_flags (ssa_name, flags);
+      if (SSA_NAME_IS_DEFAULT_DEF (ssa_name))
+	set_default_def (SSA_NAME_VAR (ssa_name), ssa_name);
       i = input_uleb128 (ib);
     } 
 }
@@ -1889,7 +1898,8 @@ lto_read_body (lto_info_fd *fd,
   if (in_function)
     {
       struct function *fn = DECL_STRUCT_FUNCTION (t);
-      cfun = fn;
+      push_cfun (fn);
+      init_tree_ssa (fn);
       data_in.num_named_labels = header->num_named_labels;
 
 #ifdef LTO_STREAM_DEBUGGING
@@ -1918,11 +1928,29 @@ lto_read_body (lto_info_fd *fd,
 #endif
       input_cfg (&ib_cfg, fn);
 
+      /* Ensure that all our variables have annotations attached to them
+	 so building SSA doesn't choke.  */
+      {
+	int i;
+
+	for (i = 0; i < header->num_var_decls; i++)
+	  add_referenced_var (data_in.var_decls[i]);
+	for (i =0; i < header->num_local_decls; i++)
+	  add_referenced_var (data_in.local_decls[i]);
+      }
+
 #ifdef LTO_STREAM_DEBUGGING
       lto_debug_context.current_data = &debug_main;
 #endif
       /* Set up the struct function.  */
       input_function (t, &data_in, &ib_main);
+
+      /* We should now be in SSA.  */
+      cfun->gimple_df->in_ssa_p = true;
+      /* Fill in properties we know hold for the rebuilt CFG.  */
+      cfun->curr_properties = PROP_ssa | PROP_alias;
+
+      pop_cfun ();
     }
   else 
     {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]