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] Fix 30 failures in check-gcc


This patch fixes ~30 failures in check-gcc.  These failures were
all due to various bits and flags in the CFG and basic blocks
that were not being streamed out.

Additionally, we were emitting empty EH regions for files that
had no EH information at all.  This was tricking lto1 into
thinking that EH should be enabled, causing random differences in
the lto1/cc1 backends.

Tested on x86_64.


Diego.



	* lto-function-out.c (output_eh_regions): Only emit EH
	regions when there is a region array for FN.
	(output_cfg): Write profile status for the function.
	Write fields 'probability' and 'count' for every basic
	block.
	(output_function): Write all bitfield flags in struct
	function for FN.
	* lto-function-in.c (input_cfg): Corresponding changes
	for reading.
	(input_function): Likewise.
	* basic-block.h (enum profile_status_d): Rename from enum
	profile_status.

Index: lto-function-out.c
===================================================================
--- lto-function-out.c	(revision 147443)
+++ lto-function-out.c	(working copy)
@@ -912,7 +912,7 @@ output_eh_regions (struct output_block *
 {
   eh_region curr;
 
-  if (fn->eh)
+  if (fn->eh && fn->eh->region_array)
     {
       unsigned i;
 
@@ -1565,9 +1565,12 @@ output_cfg (struct output_block *ob, str
 
   ob->main_stream = ob->cfg_stream;
 
+  LTO_DEBUG_TOKEN ("profile_status");
+  output_uleb128 (ob, profile_status_for_function (fn));
+
   /* Output the number of the highest basic block.  */
   LTO_DEBUG_TOKEN ("lastbb");
-  output_uleb128 (ob, last_basic_block_for_function(fn));
+  output_uleb128 (ob, last_basic_block_for_function (fn));
 
   FOR_ALL_BB_FN (bb, fn)
     {
@@ -1584,6 +1587,13 @@ output_cfg (struct output_block *ob, str
 	{
 	  LTO_DEBUG_TOKEN ("dest");
 	  output_uleb128 (ob, e->dest->index);
+
+	  LTO_DEBUG_TOKEN ("probability");
+	  output_sleb128 (ob, e->probability);
+
+	  LTO_DEBUG_TOKEN ("count");
+	  output_sleb128 (ob, e->count);
+
 	  LTO_DEBUG_TOKEN ("eflags");
 	  output_uleb128 (ob, e->flags);
 	}
@@ -1994,6 +2004,7 @@ static int function_num;
 static void
 output_function (struct cgraph_node *node)
 {
+  unsigned HOST_WIDE_INT flags;
   tree function = node->decl;
   struct function *fn = DECL_STRUCT_FUNCTION (function);
   basic_block bb;
@@ -2016,17 +2027,27 @@ output_function (struct cgraph_node *nod
 
   output_record_start (ob, NULL, NULL, LTO_function);
 
-  /* Output any exception-handling regions.  */
-  output_eh_regions (ob, fn);
-
-  /* Output the head of the arguments list.  */
-  LTO_DEBUG_INDENT_TOKEN ("decl_arguments");
-  if (DECL_ARGUMENTS (function))
-    output_expr_operand (ob, DECL_ARGUMENTS (function));
-  else
-    output_zero (ob);
+  /* Write all the attributes for FN.  Note that flags must be
+     encoded in opposite order as they are decoded in
+     input_function.  */
+  flags = 0;
+  lto_set_flag (&flags, fn->is_thunk);
+  lto_set_flag (&flags, fn->has_local_explicit_reg_vars);
+  lto_set_flag (&flags, fn->after_tree_profile);
+  lto_set_flag (&flags, fn->returns_pcc_struct);
+  lto_set_flag (&flags, fn->returns_struct);
+  lto_set_flag (&flags, fn->always_inline_functions_inlined);
+  lto_set_flag (&flags, fn->after_inlining);
+  lto_set_flag (&flags, fn->dont_save_pending_sizes_p);
+  lto_set_flag (&flags, fn->stdarg);
+  lto_set_flag (&flags, fn->has_nonlocal_label);
+  lto_set_flag (&flags, fn->calls_alloca);
+  lto_set_flag (&flags, fn->calls_setjmp);
+  lto_set_flags (&flags, fn->function_frequency, 2);
+  lto_set_flags (&flags, fn->va_list_fpr_size, 8);
+  lto_set_flags (&flags, fn->va_list_gpr_size, 8);
 
-  gcc_assert (!DECL_CONTEXT (function));
+  lto_output_uleb128_stream (ob->main_stream, flags);
 
   /* Output the static chain and non-local goto save area.  */
   if (fn->static_chain_decl)
@@ -2039,6 +2060,18 @@ output_function (struct cgraph_node *nod
   else
     output_zero (ob);
 
+  /* Output any exception-handling regions.  */
+  output_eh_regions (ob, fn);
+
+  /* Output the head of the arguments list.  */
+  LTO_DEBUG_INDENT_TOKEN ("decl_arguments");
+  if (DECL_ARGUMENTS (function))
+    output_expr_operand (ob, DECL_ARGUMENTS (function));
+  else
+    output_zero (ob);
+
+  gcc_assert (!DECL_CONTEXT (function));
+
   /* We will renumber the statements.  The code that does this uses
      the same ordering that we use for serializing them so we can use
      the same code on the other end and not have to write out the
Index: lto-function-in.c
===================================================================
--- lto-function-in.c	(revision 147443)
+++ lto-function-in.c	(working copy)
@@ -1502,6 +1502,10 @@ input_cfg (struct lto_input_block *ib, s
   init_empty_tree_cfg_for_function (fn);
   init_ssa_operands ();
 
+  LTO_DEBUG_TOKEN ("profile_status");
+  profile_status_for_function (fn) = 
+    (enum profile_status_d) lto_input_uleb128 (ib);
+
   LTO_DEBUG_TOKEN ("lastbb");
   bb_count = lto_input_uleb128 (ib);
 
@@ -1533,16 +1537,30 @@ input_cfg (struct lto_input_block *ib, s
 	  unsigned int dest_index;
 	  unsigned int edge_flags;
 	  basic_block dest;
+	  int probability;
+	  gcov_type count;
+	  edge e;
 
 	  LTO_DEBUG_TOKEN ("dest");
 	  dest_index = lto_input_uleb128 (ib);
+
+	  LTO_DEBUG_TOKEN ("probability");
+	  probability = (int) lto_input_sleb128 (ib);
+
+	  LTO_DEBUG_TOKEN ("count");
+	  count = (gcov_type) lto_input_sleb128 (ib);
+
 	  LTO_DEBUG_TOKEN ("eflags");
 	  edge_flags = lto_input_uleb128 (ib);
+
 	  dest = BASIC_BLOCK_FOR_FUNCTION (fn, dest_index);
 
 	  if (dest == NULL) 
 	    dest = make_new_block (fn, dest_index);
-	  make_edge (bb, dest, edge_flags);
+
+	  e = make_edge (bb, dest, edge_flags);
+	  e->probability = probability;
+	  e->count = count;
 	}
 
       LTO_DEBUG_TOKEN ("bbindex");
@@ -1863,6 +1881,7 @@ input_function (tree fn_decl, struct dat
   struct cgraph_edge *cedge; 
   basic_block bb;
   struct cgraph_node *node;
+  unsigned HOST_WIDE_INT flags;
 
   fn = DECL_STRUCT_FUNCTION (fn_decl);
   tag = input_record_start (ib);
@@ -1873,14 +1892,25 @@ input_function (tree fn_decl, struct dat
   gimple_register_cfg_hooks ();
   gcc_assert (tag == LTO_function);
 
-  input_eh_regions (ib, data_in, fn);
-
-  LTO_DEBUG_INDENT_TOKEN ("decl_arguments");
-  tag = input_record_start (ib);
-  if (tag)
-    DECL_ARGUMENTS (fn_decl) = input_expr_operand (ib, data_in, fn, tag); 
+  /* Read all the attributes for FN.  Note that flags are decoded in
+     the opposite order that they were encoded by output_function.  */
+  flags = lto_input_uleb128 (ib);
 
-  DECL_CONTEXT (fn_decl) = NULL_TREE;
+  fn->va_list_gpr_size = lto_get_flags (&flags, 8);
+  fn->va_list_fpr_size = lto_get_flags (&flags, 8);
+  fn->function_frequency = (enum function_frequency) lto_get_flags (&flags, 2);
+  fn->calls_setjmp = lto_get_flag (&flags);
+  fn->calls_alloca = lto_get_flag (&flags);
+  fn->has_nonlocal_label = lto_get_flag (&flags);
+  fn->stdarg = lto_get_flag (&flags);
+  fn->dont_save_pending_sizes_p = lto_get_flag (&flags);
+  fn->after_inlining = lto_get_flag (&flags);
+  fn->always_inline_functions_inlined = lto_get_flag (&flags);
+  fn->returns_struct = lto_get_flag (&flags);
+  fn->returns_pcc_struct = lto_get_flag (&flags);
+  fn->after_tree_profile = lto_get_flag (&flags);
+  fn->has_local_explicit_reg_vars = lto_get_flag (&flags);
+  fn->is_thunk = lto_get_flag (&flags);
 
   /* Read the static chain and non-local goto save area.  */
   tag = input_record_start (ib);
@@ -1891,6 +1921,15 @@ input_function (tree fn_decl, struct dat
   if (tag)
     fn->nonlocal_goto_save_area = input_expr_operand (ib, data_in, fn, tag);
 
+  input_eh_regions (ib, data_in, fn);
+
+  LTO_DEBUG_INDENT_TOKEN ("decl_arguments");
+  tag = input_record_start (ib);
+  if (tag)
+    DECL_ARGUMENTS (fn_decl) = input_expr_operand (ib, data_in, fn, tag); 
+
+  DECL_CONTEXT (fn_decl) = NULL_TREE;
+
   /* Read all the basic blocks.  */
   tag = input_record_start (ib);
   while (tag)
Index: basic-block.h
===================================================================
--- basic-block.h	(revision 147443)
+++ basic-block.h	(working copy)
@@ -382,7 +382,7 @@ struct GTY(()) control_flow_graph {
      only used for the gimple CFG.  */
   VEC(basic_block,gc) *x_label_to_block_map;
 
-  enum profile_status {
+  enum profile_status_d {
     PROFILE_ABSENT,
     PROFILE_GUESSED,
     PROFILE_READ


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