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]

[PATCH] Fix ICEs in referenced_var_lookup with LTO


This massages update_address_taken again.  The previous check for
whether a variable is in referenced vars was broken and caused
ICEs with LTO SPEC2k6 builds.  The following massages
referenced_var_lookup to be usable.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2010-07-21  Richard Guenther  <rguenther@suse.de>

	* tree-flow.h (referenced_var): Move define ...
	* tree-flow-inline.h (referenced_var): ... here as an inline
	function.  Assert here ...
	* tree-dfa.c (referenced_var_lookup): ... instead of here.
	* tree-ssa.c (maybe_optimize_var): Check if the variable
	is in referenced vars.
	(execute_update_addresses_taken): Remove old broken check.
	* gimple-pretty-print.c (pp_points_to_solution): Use
	referenced_var_lookup.
	* tree-into-ssa.c (dump_decl_set): Likewise.

Index: gcc/tree-flow.h
===================================================================
*** gcc/tree-flow.h	(revision 162340)
--- gcc/tree-flow.h	(working copy)
*************** typedef struct
*** 321,327 ****
  extern tree referenced_var_lookup (unsigned int);
  extern bool referenced_var_check_and_insert (tree);
  #define num_referenced_vars htab_elements (gimple_referenced_vars (cfun))
- #define referenced_var(i) referenced_var_lookup (i)
  
  #define num_ssa_names (VEC_length (tree, cfun->gimple_df->ssa_names))
  #define ssa_name(i) (VEC_index (tree, cfun->gimple_df->ssa_names, (i)))
--- 326,331 ----
Index: gcc/tree-flow-inline.h
===================================================================
*** gcc/tree-flow-inline.h	(revision 162340)
--- gcc/tree-flow-inline.h	(working copy)
*************** next_htab_element (htab_iterator *hti)
*** 98,103 ****
--- 98,113 ----
    return NULL;
  }
  
+ /* Get the variable with uid UID from the list of referenced vars.  */
+ 
+ static inline tree
+ referenced_var (unsigned int uid)
+ {
+   tree var = referenced_var_lookup (uid);
+   gcc_assert (var || uid == 0);
+   return var;
+ }
+ 
  /* Initialize ITER to point to the first referenced variable in the
     referenced_vars hashtable, and return that variable.  */
  
Index: gcc/tree-dfa.c
===================================================================
*** gcc/tree-dfa.c	(revision 162340)
--- gcc/tree-dfa.c	(working copy)
*************** referenced_var_lookup (unsigned int uid)
*** 495,501 ****
    struct tree_decl_minimal in;
    in.uid = uid;
    h = (tree) htab_find_with_hash (gimple_referenced_vars (cfun), &in, uid);
-   gcc_assert (h || uid == 0);
    return h;
  }
  
--- 495,500 ----
Index: gcc/tree-ssa.c
===================================================================
*** gcc/tree-ssa.c	(revision 162340)
--- gcc/tree-ssa.c	(working copy)
*************** maybe_optimize_var (tree var, bitmap add
*** 1881,1886 ****
--- 1881,1891 ----
        || bitmap_bit_p (addresses_taken, DECL_UID (var)))
      return false;
  
+   /* If the variable is not in the list of referenced vars then we
+      do not need to touch it nor can we rename it.  */
+   if (!referenced_var_lookup (DECL_UID (var)))
+     return false;
+ 
    if (TREE_ADDRESSABLE (var)
        /* Do not change TREE_ADDRESSABLE if we need to preserve var as
  	 a non-register.  Otherwise we are confused and forget to
*************** execute_update_addresses_taken (bool do_
*** 2031,2043 ****
  	 unused vars from BLOCK trees which cause code generation
  	 differences for -g vs. -g0.  */
        for (var = DECL_ARGUMENTS (cfun->decl); var; var = DECL_CHAIN (var))
! 	{
! 	  /* ???  Not all arguments are in referenced vars.  */
! 	  if (!var_ann (var))
! 	    continue;
! 	  update_vops
! 	    |= maybe_optimize_var (var, addresses_taken, not_reg_needs);
! 	}
        for (i = 0; VEC_iterate (tree, cfun->local_decls, i, var); ++i)
  	update_vops |= maybe_optimize_var (var, addresses_taken, not_reg_needs);
      }
--- 2036,2042 ----
  	 unused vars from BLOCK trees which cause code generation
  	 differences for -g vs. -g0.  */
        for (var = DECL_ARGUMENTS (cfun->decl); var; var = DECL_CHAIN (var))
! 	update_vops |= maybe_optimize_var (var, addresses_taken, not_reg_needs);
        for (i = 0; VEC_iterate (tree, cfun->local_decls, i, var); ++i)
  	update_vops |= maybe_optimize_var (var, addresses_taken, not_reg_needs);
      }
Index: gcc/gimple-pretty-print.c
===================================================================
*** gcc/gimple-pretty-print.c	(revision 162340)
--- gcc/gimple-pretty-print.c	(working copy)
*************** pp_points_to_solution (pretty_printer *b
*** 534,544 ****
        pp_string (buffer, "{ ");
        EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
  	{
! 	  struct tree_decl_minimal in;
! 	  tree var;
! 	  in.uid = i;
! 	  var = (tree) htab_find_with_hash (gimple_referenced_vars (cfun),
! 					    &in, i);
  	  if (var)
  	    {
  	      dump_generic_node (buffer, var, 0, dump_flags, false);
--- 534,540 ----
        pp_string (buffer, "{ ");
        EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
  	{
! 	  tree var = referenced_var_lookup (i);
  	  if (var)
  	    {
  	      dump_generic_node (buffer, var, 0, dump_flags, false);
Index: gcc/tree-into-ssa.c
===================================================================
*** gcc/tree-into-ssa.c	(revision 162340)
--- gcc/tree-into-ssa.c	(working copy)
*************** dump_decl_set (FILE *file, bitmap set)
*** 1470,1480 ****
  
        EXECUTE_IF_SET_IN_BITMAP (set, 0, i, bi)
  	{
! 	  struct tree_decl_minimal in;
! 	  tree var;
! 	  in.uid = i;
! 	  var = (tree) htab_find_with_hash (gimple_referenced_vars (cfun),
! 					    &in, i);
  	  if (var)
  	    print_generic_expr (file, var, 0);
  	  else
--- 1470,1476 ----
  
        EXECUTE_IF_SET_IN_BITMAP (set, 0, i, bi)
  	{
! 	  tree var = referenced_var_lookup (i);
  	  if (var)
  	    print_generic_expr (file, var, 0);
  	  else


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