My earlier patch for 87269 got me thinking and I realized that now we don't order the non-hidden overload members, we can no longer get into the situation of needing to mutate non-hidden overload members. We only prepend. So all the lookup keeping & ovl marking machinery can go away. It is unreachable.

Applying to trunk.

nathan
--
Nathan Sidwell
2018-11-16  Nathan Sidwell  <nat...@acm.org>

	Remove ovl_used, it is no longer needed
	* cp-tree.h (OVL_USED_P): Delete.
	(lookup_keep): Delete.
	* friend.c (add_friend): Don't call it.
	* parser.c (lookup_literal_operator): Likewise.
	(cp_parser_primary_expression): Likewise.
	* semantics.c (perform_koenig_lookup): Likewise.
	* pt.c (tsubst_copy <OVERLOAD>): Don't assert OVL_USED_P.
	* tree.c (ovl_copy): Delete.
	(ovl_insert): Remove OVL_USED_P checks.
	(ovl_iterator::reveal_node): Likewise.
	(ovl_iterator::remove__node): Likewise.
	(ovl_used, lookup_keep): Delete.

Index: gcc/cp/cp-tree.h
===================================================================
--- gcc/cp/cp-tree.h	(revision 266210)
+++ gcc/cp/cp-tree.h	(working copy)
@@ -706,8 +706,6 @@ typedef struct ptrmem_cst * ptrmem_cst_t
 #define OVL_NESTED_P(NODE)	TREE_LANG_FLAG_3 (OVERLOAD_CHECK (NODE))
 /* If set, this overload was constructed during lookup.  */
 #define OVL_LOOKUP_P(NODE)	TREE_LANG_FLAG_4 (OVERLOAD_CHECK (NODE))
-/* If set, this is a persistant lookup. */
-#define OVL_USED_P(NODE)	TREE_USED (OVERLOAD_CHECK (NODE))
 
 /* The first decl of an overload.  */
 #define OVL_FIRST(NODE)	ovl_first (NODE)
@@ -7222,7 +7220,6 @@ extern void lookup_mark				(tree lookup,
 extern tree lookup_add				(tree fns, tree lookup);
 extern tree lookup_maybe_add			(tree fns, tree lookup,
 						 bool deduping);
-extern void lookup_keep				(tree lookup);
 extern int is_overloaded_fn			(tree) ATTRIBUTE_PURE;
 extern bool really_overloaded_fn		(tree) ATTRIBUTE_PURE;
 extern tree dependent_name			(tree);
Index: gcc/cp/friend.c
===================================================================
--- gcc/cp/friend.c	(revision 266210)
+++ gcc/cp/friend.c	(working copy)
@@ -173,12 +173,6 @@ add_friend (tree type, tree decl, bool c
   if (decl == error_mark_node)
     return;
 
-  if (TREE_CODE (decl) == FUNCTION_DECL
-      && DECL_TEMPLATE_INSTANTIATION (decl))
-    /* We'll have parsed this as a declaration, and therefore not
-       marked the lookup set for keeping.  Do that now.  */
-    lookup_keep (DECL_TI_TEMPLATE (decl));
-
   typedecl = TYPE_MAIN_DECL (type);
   list = DECL_FRIENDLIST (typedecl);
   name = DECL_NAME (decl);
Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c	(revision 266210)
+++ gcc/cp/parser.c	(working copy)
@@ -4294,11 +4294,7 @@ lookup_literal_operator (tree name, vec<
 		 work in presence of default arguments on the literal
 		 operator parameters.  */
 	      && parmtypes == void_list_node)
-	    {
-	      if (processing_template_decl)
-		lookup_keep (decl);
-	      return decl;
-	    }
+	    return decl;
 	}
     }
 
@@ -5684,14 +5680,6 @@ cp_parser_primary_expression (cp_parser
 	      }
 	  }
 
-	if (processing_template_decl)
-	  if (tree fns = maybe_get_fns (decl))
-	    /* It's too difficult to mark ths in all the places where
-	       we know for sure we need to keep the lookup, so do it
-	       now.  The cost is extra GC to recycle the lookups
-	       resolved at parse time.  */
-	    lookup_keep (fns);
-
 	decl = (finish_id_expression
 		(id_expression, decl, parser->scope,
 		 idk,
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c	(revision 266210)
+++ gcc/cp/pt.c	(working copy)
@@ -15541,8 +15541,6 @@ tsubst_copy (tree t, tree args, tsubst_f
       return t;
 
     case OVERLOAD:
-      /* We must have marked any lookups as persistent.  */
-      gcc_assert (!OVL_LOOKUP_P (t) || OVL_USED_P (t));
       return t;
 
     case BASELINK:
Index: gcc/cp/semantics.c
===================================================================
--- gcc/cp/semantics.c	(revision 266210)
+++ gcc/cp/semantics.c	(working copy)
@@ -2345,11 +2345,6 @@ perform_koenig_lookup (cp_expr fn, vec<t
 	  else
 	    fn = identifier;
 	}
-      else if (TREE_CODE (fn) == OVERLOAD && processing_template_decl)
-	/* FIXME: We shouldn't really need to mark the lookup here, as
-	   resolving the (non-dependent) call should save the single
-	   function we resolve to.  Related to PR c++/83529.  */
-	lookup_keep (fn);
     }
 
   if (fn && template_id && fn != error_mark_node)
Index: gcc/cp/tree.c
===================================================================
--- gcc/cp/tree.c	(revision 266210)
+++ gcc/cp/tree.c	(working copy)
@@ -2167,23 +2167,6 @@ ovl_make (tree fn, tree next)
   return result;
 }
 
-static tree
-ovl_copy (tree ovl)
-{
-  tree result = make_node (OVERLOAD);
-
-  gcc_checking_assert (!OVL_NESTED_P (ovl) && OVL_USED_P (ovl));
-  TREE_TYPE (result) = TREE_TYPE (ovl);
-  OVL_FUNCTION (result) = OVL_FUNCTION (ovl);
-  OVL_CHAIN (result) = OVL_CHAIN (ovl);
-  OVL_DEDUP_P (result) = OVL_DEDUP_P (ovl);
-  OVL_LOOKUP_P (result) = OVL_LOOKUP_P (ovl);
-  OVL_HIDDEN_P (result) = OVL_HIDDEN_P (ovl);
-  OVL_USING_P (result) = OVL_USING_P (ovl);
-
-  return result;
-}
-
 /* Add FN to the (potentially NULL) overload set OVL.  USING_P is
    true, if FN is via a using declaration.  We also pay attention to
    DECL_HIDDEN.  We keep the hidden decls first, but remaining ones
@@ -2200,8 +2183,7 @@ ovl_insert (tree fn, tree maybe_ovl, boo
 	 && OVL_HIDDEN_P (maybe_ovl);
        maybe_ovl = OVL_CHAIN (maybe_ovl))
     {
-      gcc_checking_assert (!OVL_LOOKUP_P (maybe_ovl)
-			   && !OVL_USED_P (maybe_ovl));
+      gcc_checking_assert (!OVL_LOOKUP_P (maybe_ovl));
       insert_after = maybe_ovl;
     }
 
@@ -2254,9 +2236,8 @@ ovl_skip_hidden (tree ovl)
 tree
 ovl_iterator::reveal_node (tree overload, tree node)
 {
-  /* We cannot have returned NODE as part of a lookup overload, so it
-     cannot be USED.  */
-  gcc_checking_assert (!OVL_USED_P (node));
+  /* We cannot have returned NODE as part of a lookup overload, so we
+     don't have to worry about preserving that.  */
 
   OVL_HIDDEN_P (node) = false;
   if (tree chain = OVL_CHAIN (node))
@@ -2275,8 +2256,7 @@ ovl_iterator::reveal_node (tree overload
   return overload;
 }
 
-/* NODE is on the overloads of OVL.  Remove it.  If a predecessor is
-   OVL_USED_P we must copy OVL nodes, because those are immutable.
+/* NODE is on the overloads of OVL.  Remove it.  
    The removed node is unaltered and may continue to be iterated
    from (i.e. it is safe to remove a node from an overload one is
    currently iterating over).  */
@@ -2284,20 +2264,11 @@ ovl_iterator::reveal_node (tree overload
 tree
 ovl_iterator::remove_node (tree overload, tree node)
 {
-  bool copying = false; /* Checking use only.  */
-
   tree *slot = &overload;
   while (*slot != node)
     {
       tree probe = *slot;
-      gcc_checking_assert (!OVL_LOOKUP_P (probe)
-			   && (!copying || OVL_USED_P (probe)));
-      if (OVL_USED_P (probe))
-	{
-	  copying = true;
-	  probe = ovl_copy (probe);
-	  *slot = probe;
-	}
+      gcc_checking_assert (!OVL_LOOKUP_P (probe));
 
       slot = &OVL_CHAIN (probe);
     }
@@ -2388,40 +2359,6 @@ lookup_maybe_add (tree fns, tree lookup,
   return lookup;
 }
 
-/* Regular overload OVL is part of a kept lookup.  Mark the nodes on
-   it as immutable.  */
-
-static void
-ovl_used (tree ovl)
-{
-  for (;
-       ovl && TREE_CODE (ovl) == OVERLOAD
-	 && !OVL_USED_P (ovl);
-       ovl = OVL_CHAIN (ovl))
-    {
-      gcc_checking_assert (!OVL_LOOKUP_P (ovl));
-      OVL_USED_P (ovl) = true;
-    }
-}
-
-/* Preserve the contents of a lookup so that it is available for a
-   later instantiation.  */
-
-void
-lookup_keep (tree lookup)
-{
-  for (;
-       lookup && TREE_CODE (lookup) == OVERLOAD
-	 && OVL_LOOKUP_P (lookup) && !OVL_USED_P (lookup);
-       lookup = OVL_CHAIN (lookup))
-    {
-      OVL_USED_P (lookup) = true;
-      ovl_used (OVL_FUNCTION (lookup));
-    }
-
-  ovl_used (lookup);
-}
-
 /* Returns nonzero if X is an expression for a (possibly overloaded)
    function.  If "f" is a function or function template, "f", "c->f",
    "c.f", "C::f", and "f<int>" will all be considered possibly

Reply via email to