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]

checked in patch for PR 27793


I checked the following patch in the 4.1 branch. bootstrapped and no new
regressions on i686-pc-linux-gnu.

4.2 to follow later.

Andrew



	PR middle-end/27793
	* tree-dfa.c (referenced_vars_dup_list): New.  List of duplicate 
	referenced_variables with matching DECL_UID's.
	(find_referenced_vars): Make sure duplicate list is empty to start.
	(add_referenced_var): Add var to duplicate list if required.
	* tree-ssa.c (delete_tree_ssa): Clear var_ann's on duplicates.
	* tree-flow.h (referenced_vars_dup_list): External declaration.

Index: tree-dfa.c
===================================================================
*** tree-dfa.c	(revision 114129)
--- tree-dfa.c	(working copy)
*************** static void add_referenced_var (tree, bo
*** 76,81 ****
--- 76,83 ----
  
  /* Array of all variables referenced in the function.  */
  htab_t referenced_vars;
+ /* List of referenced variables with duplicate UID's.  */
+ VEC(tree,gc) *referenced_vars_dup_list;
  
  
  /*---------------------------------------------------------------------------
*************** find_referenced_vars (void)
*** 95,100 ****
--- 97,103 ----
    basic_block bb;
    block_stmt_iterator si;
  
+   gcc_assert (VEC_length (tree, referenced_vars_dup_list) == 0);
    FOR_EACH_BB (bb)
      for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
        {
*************** static void
*** 610,620 ****
  add_referenced_var (tree var, bool always)
  {
    var_ann_t v_ann;
  
    v_ann = get_var_ann (var);
    gcc_assert (DECL_P (var));
    
!   if (always || referenced_var_lookup_if_exists (DECL_UID (var)) == NULL_TREE)
      {
        /* This is the first time we find this variable, add it to the
           REFERENCED_VARS array and annotate it with attributes that are
--- 613,643 ----
  add_referenced_var (tree var, bool always)
  {
    var_ann_t v_ann;
+   tree dup = referenced_var_lookup_if_exists (DECL_UID (var));
  
    v_ann = get_var_ann (var);
    gcc_assert (DECL_P (var));
    
!   /* PRs 26757 and 27793.  Maintain a list of duplicate variable pointers
!      with the same DECL_UID.  There isn't usually very many.  
!      TODO.  Once the C++ front end doesn't create duplicate DECL UID's, this
!      code can be removed.  */
!   if (dup && dup != var)
!     {
!       unsigned u;
!       tree t = NULL_TREE;
! 
!       for (u = 0; u < VEC_length (tree, referenced_vars_dup_list); u++)
! 	{
! 	  t = VEC_index (tree, referenced_vars_dup_list, u);
! 	  if (t == var)
! 	    break;
! 	}
!       if (t != var)
! 	VEC_safe_push (tree, gc, referenced_vars_dup_list, var);
!     }
! 
!   if (always || dup == NULL_TREE)
      {
        /* This is the first time we find this variable, add it to the
           REFERENCED_VARS array and annotate it with attributes that are
Index: tree-ssa.c
===================================================================
*** tree-ssa.c	(revision 114129)
--- tree-ssa.c	(working copy)
*************** delete_tree_ssa (void)
*** 821,826 ****
--- 821,827 ----
    block_stmt_iterator bsi;
    referenced_var_iterator rvi;
    tree var;
+   unsigned u;
  
    /* Release any ssa_names still in use.  */
    for (i = 0; i < num_ssa_names; i++)
*************** delete_tree_ssa (void)
*** 855,860 ****
--- 856,871 ----
        ggc_free (var->common.ann);
        var->common.ann = NULL;
      }
+ 
+   /* Remove any referenced variables which had duplicate UID's.  */
+   for (u = 0; u < VEC_length (tree, referenced_vars_dup_list); u++)
+     {
+       var = VEC_index (tree, referenced_vars_dup_list, u);
+       ggc_free (var->common.ann);
+       var->common.ann = NULL;
+     }
+   VEC_free (tree, gc, referenced_vars_dup_list);
+ 
    htab_delete (referenced_vars);
    referenced_vars = NULL;
  
Index: tree-flow.h
===================================================================
*** tree-flow.h	(revision 114129)
--- tree-flow.h	(working copy)
*************** typedef struct
*** 420,425 ****
--- 420,427 ----
  
  /* Array of all variables referenced in the function.  */
  extern GTY((param_is (struct int_tree_map))) htab_t referenced_vars;
+ /* List of referenced variables in the function with duplicate UID's.  */
+ extern VEC(tree,gc) *referenced_vars_dup_list;
  
  extern tree referenced_var_lookup (unsigned int);
  extern tree referenced_var_lookup_if_exists (unsigned int);

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