[PATCH v4 03/10] OpenMP: Remove dead code from declare variant reimplementation

Sandra Loosemore sloosemore@baylibre.com
Sat Nov 16 04:06:59 GMT 2024


After reimplementing late resolution of "declare variant", the
declare_variant_alt and calls_declare_variant_alt flags on struct
cgraph_node are no longer used by anything.  For the purposes of
marking functions that need late resolution, the
has_omp_variant_constructs flag has replaced
calls_declare_variant_alt.

Likewise struct omp_declare_variant_entry, struct
omp_declare_variant_base_entry, and the hash tables used to store
these structures are no longer needed, since the information needed for
late resolution is now stored in the gomp_variant_construct nodes.

In addition, some obsolete code that was temporarily ifdef'ed out
instead of delted in order to produce a more readable patch for the
previous installment of this series is now removed entirely.

There are no functional changes in this patch, just removing dead code.

gcc/ChangeLog
	* cgraph.cc (symbol_table::create_edge): Don't set
	calls_declare_variant_alt in the caller.
	* cgraph.h (struct cgraph_node): Remove declare_variant_alt
	and calls_declare_variant_alt flags.
	* cgraphclones.cc (cgraph_node::create_clone): Don't copy
	calls_declare_variant_alt bit.
	* ipa-free-lang-data.cc (free_lang_data_in_decl): Adjust code
	referencing declare_variant_alt bit.
	* ipa.cc (symbol_table::remove_unreachable_nodes): Likewise.
	* lto-cgraph.cc (lto_output_node): Remove references to deleted
	bits.
	(output_refs): Adjust code referencing declare_variant_alt bit.
	(input_overwrite_node): Remove references to deleted bits.
	(input_refs): Adjust code referencing declare_variant_alt bit.
	* lto-streamer-out.cc (lto_output): Likewise.
	* lto-streamer.h (omp_lto_output_declare_variant_alt): Delete.
	(omp_lto_input_declare_variant_alt): Delete.
	* lto/lto-partition.cc (lto_balanced_map): Adjust code referencing
	deleted declare_variant_alt bit.
	* omp-expand.cc (expand_omp_target): Use has_omp_variant_constructs bit to
	trigger pass_omp_device_lower instead of calls_declare_variant_alt.
	* omp-general.cc (struct omp_declare_variant_entry): Delete.
	(struct omp_declare_variant_base_entry): Delete.
	(struct omp_declare_variant_hasher): Delete.
	(omp_declare_variant_hasher::hash): Delete.
	(omp_declare_variant_hasher::equal): Delete.
	(omp_declare_variants): Delete.
	(omp_declare_variant_alt_hasher): Delete.
	(omp_declare_variant_alt_hasher::hash): Delete.
	(omp_declare_variant_alt_hasher::equal): Delete.
	(omp_declare_variant_alt): Delete.
	(omp_lto_output_declare_variant_alt): Delete.
	(omp_lto_input_declare_variant_alt): Delete.
	(includes): Delete unnecessary include of gt-omp-general.h.
	* omp-offload.cc (execute_omp_device_lower): Remove references
	to deleted bit.
	(pass_omp_device_lower::gate): Likewise.
	* omp-simd-clone.cc (simd_clone_create): Likewise.
	* passes.cc (ipa_write_summaries): Likeise.
	* symtab.cc (symtab_node::get_partitioning_class): Likewise.
	* tree-inline.cc (expand_call_inline): Likewise.
	(tree_function_versioning): Likewise.
---
 gcc/cgraph.cc             |    2 -
 gcc/cgraph.h              |   11 +-
 gcc/cgraphclones.cc       |    1 -
 gcc/gimplify.cc           |  149 -----
 gcc/ipa-free-lang-data.cc |    2 +-
 gcc/ipa.cc                |    3 -
 gcc/lto-cgraph.cc         |   10 -
 gcc/lto-streamer-out.cc   |    3 +-
 gcc/lto-streamer.h        |    6 -
 gcc/lto/lto-partition.cc  |    5 +-
 gcc/omp-expand.cc         |    2 +-
 gcc/omp-general.cc        | 1092 -------------------------------------
 gcc/omp-offload.cc        |    8 +-
 gcc/omp-simd-clone.cc     |    2 -
 gcc/passes.cc             |    3 +-
 gcc/symtab.cc             |    2 +-
 gcc/tree-inline.cc        |    4 -
 17 files changed, 10 insertions(+), 1295 deletions(-)

diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index d4c35341ab5..c7ed0880916 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -933,8 +933,6 @@ symbol_table::create_edge (cgraph_node *caller, cgraph_node *callee,
 				      caller->decl);
   else
     edge->in_polymorphic_cdtor = caller->thunk;
-  if (callee)
-    caller->calls_declare_variant_alt |= callee->declare_variant_alt;
 
   if (callee && symtab->state != LTO_STREAMING
       && edge->callee->comdat_local_p ())
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 92875c6d368..5a3fcb20437 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -897,10 +897,8 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node
       split_part (false), indirect_call_target (false), local (false),
       versionable (false), can_change_signature (false),
       redefined_extern_inline (false), tm_may_enter_irr (false),
-      ipcp_clone (false), declare_variant_alt (false),
-      calls_declare_variant_alt (false), gc_candidate (false),
-      called_by_ifunc_resolver (false),
-      has_omp_variant_constructs (false),
+      ipcp_clone (false), gc_candidate (false),
+      called_by_ifunc_resolver (false), has_omp_variant_constructs (false),
       m_uid (uid), m_summary_id (-1)
   {}
 
@@ -1491,11 +1489,6 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node
   unsigned tm_may_enter_irr : 1;
   /* True if this was a clone created by ipa-cp.  */
   unsigned ipcp_clone : 1;
-  /* True if this is the deferred declare variant resolution artificial
-     function.  */
-  unsigned declare_variant_alt : 1;
-  /* True if the function calls declare_variant_alt functions.  */
-  unsigned calls_declare_variant_alt : 1;
   /* True if the function should only be emitted if it is used.  This flag
      is set for local SIMD clones when they are created and cleared if the
      vectorizer uses them.  */
diff --git a/gcc/cgraphclones.cc b/gcc/cgraphclones.cc
index 03aadc66461..070926b0a87 100644
--- a/gcc/cgraphclones.cc
+++ b/gcc/cgraphclones.cc
@@ -389,7 +389,6 @@ cgraph_node::create_clone (tree new_decl, profile_count prof_count,
   if (!new_inlined_to)
     prof_count = count.combine_with_ipa_count (prof_count);
   new_node->count = prof_count;
-  new_node->calls_declare_variant_alt = this->calls_declare_variant_alt;
   new_node->has_omp_variant_constructs = this->has_omp_variant_constructs;
 
   /* Update IPA profile.  Local profiles need no updating in original.  */
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 1afa2a07ea0..588934ef469 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -14961,155 +14961,6 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, gimple_seq body, tree *list_p,
   delete_omp_context (ctx);
 }
 
-#if 0
-/* Return 0 if CONSTRUCTS selectors don't match the OpenMP context,
-   -1 if unknown yet (simd is involved, won't be known until vectorization)
-   and 1 if they do.  If SCORES is non-NULL, it should point to an array
-   of at least 2*NCONSTRUCTS+2 ints, and will be filled with the positions
-   of the CONSTRUCTS (position -1 if it will never match) followed by
-   number of constructs in the OpenMP context construct trait.  If the
-   score depends on whether it will be in a declare simd clone or not,
-   the function returns 2 and there will be two sets of the scores, the first
-   one for the case that it is not in a declare simd clone, the other
-   that it is in a declare simd clone.  */
-
-int
-omp_construct_selector_matches (enum tree_code *constructs, int nconstructs,
-				int *scores)
-{
-  int matched = 0, cnt = 0;
-  bool simd_seen = false;
-  bool target_seen = false;
-  int declare_simd_cnt = -1;
-  auto_vec<enum tree_code, 16> codes;
-  for (struct gimplify_omp_ctx *ctx = gimplify_omp_ctxp; ctx;)
-    {
-      if (((ctx->region_type & ORT_PARALLEL) && ctx->code == OMP_PARALLEL)
-	  || ((ctx->region_type & (ORT_TARGET | ORT_IMPLICIT_TARGET | ORT_ACC))
-	      == ORT_TARGET && ctx->code == OMP_TARGET)
-	  || ((ctx->region_type & ORT_TEAMS) && ctx->code == OMP_TEAMS)
-	  || (ctx->region_type == ORT_WORKSHARE && ctx->code == OMP_FOR)
-	  || (ctx->region_type == ORT_SIMD
-	      && ctx->code == OMP_SIMD
-	      && !omp_find_clause (ctx->clauses, OMP_CLAUSE_BIND)))
-	{
-	  ++cnt;
-	  if (scores)
-	    codes.safe_push (ctx->code);
-	  else if (matched < nconstructs && ctx->code == constructs[matched])
-	    {
-	      if (ctx->code == OMP_SIMD)
-		{
-		  if (matched)
-		    return 0;
-		  simd_seen = true;
-		}
-	      ++matched;
-	    }
-	  if (ctx->code == OMP_TARGET)
-	    {
-	      if (scores == NULL)
-		return matched < nconstructs ? 0 : simd_seen ? -1 : 1;
-	      target_seen = true;
-	      break;
-	    }
-	}
-      else if (ctx->region_type == ORT_WORKSHARE
-	       && ctx->code == OMP_LOOP
-	       && ctx->outer_context
-	       && ctx->outer_context->region_type == ORT_COMBINED_PARALLEL
-	       && ctx->outer_context->outer_context
-	       && ctx->outer_context->outer_context->code == OMP_LOOP
-	       && ctx->outer_context->outer_context->distribute)
-	ctx = ctx->outer_context->outer_context;
-      ctx = ctx->outer_context;
-    }
-  if (!target_seen
-      && lookup_attribute ("omp declare simd",
-			   DECL_ATTRIBUTES (current_function_decl)))
-    {
-      /* Declare simd is a maybe case, it is supposed to be added only to the
-	 omp-simd-clone.cc added clones and not to the base function.  */
-      declare_simd_cnt = cnt++;
-      if (scores)
-	codes.safe_push (OMP_SIMD);
-      else if (cnt == 0
-	       && constructs[0] == OMP_SIMD)
-	{
-	  gcc_assert (matched == 0);
-	  simd_seen = true;
-	  if (++matched == nconstructs)
-	    return -1;
-	}
-    }
-  if (tree attr = lookup_attribute ("omp declare variant variant",
-				    DECL_ATTRIBUTES (current_function_decl)))
-    {
-      tree selectors = TREE_VALUE (attr);
-      int variant_nconstructs = list_length (selectors);
-      enum tree_code *variant_constructs = NULL;
-      if (!target_seen && variant_nconstructs)
-	{
-	  variant_constructs
-	    = (enum tree_code *) alloca (variant_nconstructs
-					 * sizeof (enum tree_code));
-	  omp_construct_traits_to_codes (selectors, variant_nconstructs,
-					 variant_constructs);
-	}
-      for (int i = 0; i < variant_nconstructs; i++)
-	{
-	  ++cnt;
-	  if (scores)
-	    codes.safe_push (variant_constructs[i]);
-	  else if (matched < nconstructs
-		   && variant_constructs[i] == constructs[matched])
-	    {
-	      if (variant_constructs[i] == OMP_SIMD)
-		{
-		  if (matched)
-		    return 0;
-		  simd_seen = true;
-		}
-	      ++matched;
-	    }
-	}
-    }
-  if (!target_seen
-      && lookup_attribute ("omp declare target block",
-			   DECL_ATTRIBUTES (current_function_decl)))
-    {
-      if (scores)
-	codes.safe_push (OMP_TARGET);
-      else if (matched < nconstructs && constructs[matched] == OMP_TARGET)
-	++matched;
-    }
-  if (scores)
-    {
-      for (int pass = 0; pass < (declare_simd_cnt == -1 ? 1 : 2); pass++)
-	{
-	  int j = codes.length () - 1;
-	  for (int i = nconstructs - 1; i >= 0; i--)
-	    {
-	      while (j >= 0
-		     && (pass != 0 || declare_simd_cnt != j)
-		     && constructs[i] != codes[j])
-		--j;
-	      if (pass == 0 && declare_simd_cnt != -1 && j > declare_simd_cnt)
-		*scores++ = j - 1;
-	      else
-		*scores++ = j;
-	    }
-	  *scores++ = ((pass == 0 && declare_simd_cnt != -1)
-		       ? codes.length () - 1 : codes.length ());
-	}
-      return declare_simd_cnt == -1 ? 1 : 2;
-    }
-  if (matched == nconstructs)
-    return simd_seen ? -1 : 1;
-  return 0;
-}
-#endif
-
 /* Collect a list of traits for enclosing constructs in the current
    OpenMP context.  The list is in the same format as the trait selector
    list of construct trait sets built by the front ends.
diff --git a/gcc/ipa-free-lang-data.cc b/gcc/ipa-free-lang-data.cc
index 80e30f58754..58e3a5d3a31 100644
--- a/gcc/ipa-free-lang-data.cc
+++ b/gcc/ipa-free-lang-data.cc
@@ -576,7 +576,7 @@ free_lang_data_in_decl (tree decl, class free_lang_data_d *fld)
       if (!(node = cgraph_node::get (decl))
 	  || (!node->definition && !node->clones))
 	{
-	  if (node && !node->declare_variant_alt)
+	  if (node)
 	    node->release_body ();
 	  else
 	    {
diff --git a/gcc/ipa.cc b/gcc/ipa.cc
index ffad7e73cd6..a138cdb9313 100644
--- a/gcc/ipa.cc
+++ b/gcc/ipa.cc
@@ -451,9 +451,6 @@ symbol_table::remove_unreachable_nodes (FILE *file)
 			reachable.add (body);
 		      reachable.add (e->callee);
 		    }
-		  else if (e->callee->declare_variant_alt
-			   && !e->callee->in_other_partition)
-		    reachable.add (e->callee);
 		  enqueue_node (e->callee, &first, &reachable);
 		}
 
diff --git a/gcc/lto-cgraph.cc b/gcc/lto-cgraph.cc
index d512ed7a0c6..63bd0dd70d8 100644
--- a/gcc/lto-cgraph.cc
+++ b/gcc/lto-cgraph.cc
@@ -549,8 +549,6 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
   bp_pack_value (&bp, node->merged_extern_inline, 1);
   bp_pack_value (&bp, node->thunk, 1);
   bp_pack_value (&bp, node->parallelized_function, 1);
-  bp_pack_value (&bp, node->declare_variant_alt, 1);
-  bp_pack_value (&bp, node->calls_declare_variant_alt, 1);
   bp_pack_value (&bp, node->has_omp_variant_constructs, 1);
 
   /* Stream thunk info always because we use it in
@@ -781,9 +779,6 @@ output_refs (lto_symtab_encoder_t encoder)
 	  for (int i = 0; node->iterate_reference (i, ref); i++)
 	    lto_output_ref (ob, ref, encoder);
 	}
-      if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node))
-	if (cnode->declare_variant_alt)
-	  omp_lto_output_declare_variant_alt (ob, cnode, encoder);
     }
 
   streamer_write_uhwi_stream (ob->main_stream, 0);
@@ -1257,8 +1252,6 @@ input_overwrite_node (struct lto_file_decl_data *file_data,
   node->merged_extern_inline = bp_unpack_value (bp, 1);
   node->thunk = bp_unpack_value (bp, 1);
   node->parallelized_function = bp_unpack_value (bp, 1);
-  node->declare_variant_alt = bp_unpack_value (bp, 1);
-  node->calls_declare_variant_alt = bp_unpack_value (bp, 1);
   node->has_omp_variant_constructs = bp_unpack_value (bp, 1);
   *has_thunk_info = bp_unpack_value (bp, 1);
   node->resolution = bp_unpack_enum (bp, ld_plugin_symbol_resolution,
@@ -1669,9 +1662,6 @@ input_refs (class lto_input_block *ib,
 	  input_ref (ib, node, nodes);
 	  count--;
 	}
-      if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node))
-	if (cnode->declare_variant_alt)
-	  omp_lto_input_declare_variant_alt (ib, cnode, nodes);
     }
 }
 
diff --git a/gcc/lto-streamer-out.cc b/gcc/lto-streamer-out.cc
index ec6d8a25bb0..577cbc55965 100644
--- a/gcc/lto-streamer-out.cc
+++ b/gcc/lto-streamer-out.cc
@@ -2813,8 +2813,7 @@ lto_output (void)
 		  && flag_incremental_link != INCREMENTAL_LINK_LTO)
 	      /* Thunks have no body but they may be synthetized
 		 at WPA time.  */
-	      || DECL_ARGUMENTS (cnode->decl)
-	      || cnode->declare_variant_alt))
+	      || DECL_ARGUMENTS (cnode->decl)))
 	output_function (cnode);
       else if ((vnode = dyn_cast <varpool_node *> (snode))
 	       && (DECL_INITIAL (vnode->decl) != error_mark_node
diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
index 1c416a7a1b9..99b980ce6af 100644
--- a/gcc/lto-streamer.h
+++ b/gcc/lto-streamer.h
@@ -944,12 +944,6 @@ bool reachable_from_this_partition_p (struct cgraph_node *,
 lto_symtab_encoder_t compute_ltrans_boundary (lto_symtab_encoder_t encoder);
 void select_what_to_stream (void);
 
-/* In omp-general.cc.  */
-void omp_lto_output_declare_variant_alt (lto_simple_output_block *,
-					 cgraph_node *, lto_symtab_encoder_t);
-void omp_lto_input_declare_variant_alt (lto_input_block *, cgraph_node *,
-					vec<symtab_node *>);
-
 /* In options-save.cc.  */
 void cl_target_option_stream_out (struct output_block *, struct bitpack_d *,
 				  struct cl_target_option *);
diff --git a/gcc/lto/lto-partition.cc b/gcc/lto/lto-partition.cc
index 395831f96a6..e75293dcd64 100644
--- a/gcc/lto/lto-partition.cc
+++ b/gcc/lto/lto-partition.cc
@@ -1181,8 +1181,7 @@ lto_balanced_map (int n_lto_partitions, int max_partition_size)
 
 	      last_visited_node++;
 
-	      gcc_assert (node->definition || node->weakref
-			  || node->declare_variant_alt);
+	      gcc_assert (node->definition || node->weakref);
 
 	      /* Compute boundary cost of callgraph edges.  */
 	      for (edge = node->callees; edge; edge = edge->next_callee)
@@ -1293,7 +1292,7 @@ lto_balanced_map (int n_lto_partitions, int max_partition_size)
 		int index;
 
 		node = dyn_cast <cgraph_node *> (ref->referring);
-		gcc_assert (node->definition || node->declare_variant_alt);
+		gcc_assert (node->definition);
 		index = lto_symtab_encoder_lookup (partition->encoder,
 						   node);
 		if (index != LCC_NOT_FOUND
diff --git a/gcc/omp-expand.cc b/gcc/omp-expand.cc
index 9926de8f523..51d74661ed4 100644
--- a/gcc/omp-expand.cc
+++ b/gcc/omp-expand.cc
@@ -10147,7 +10147,7 @@ expand_omp_target (struct omp_region *region)
 
 	  /* Enable pass_omp_device_lower pass.  */
 	  fn2_node = cgraph_node::get (DECL_CONTEXT (child_fn));
-	  fn2_node->calls_declare_variant_alt = 1;
+	  fn2_node->has_omp_variant_constructs = 1;
 
 	  t = build_decl (DECL_SOURCE_LOCATION (child_fn),
 			  RESULT_DECL, NULL_TREE, void_type_node);
diff --git a/gcc/omp-general.cc b/gcc/omp-general.cc
index ea83bb14f7d..10fce27eae5 100644
--- a/gcc/omp-general.cc
+++ b/gcc/omp-general.cc
@@ -1050,31 +1050,6 @@ omp_max_simt_vf (void)
   return 0;
 }
 
-/* Store the construct selectors as tree codes from last to first.
-   CTX is a list of trait selectors, nconstructs must be equal to its
-   length, and the array CONSTRUCTS holds the output.  */
-
-void
-omp_construct_traits_to_codes (tree ctx, int nconstructs,
-			       enum tree_code *constructs)
-{
-  int i = nconstructs - 1;
-
-  /* Order must match the OMP_TRAIT_CONSTRUCT_* enumerators in
-     enum omp_ts_code.  */
-  static enum tree_code code_map[]
-    = { OMP_TARGET, OMP_TEAMS, OMP_PARALLEL, OMP_FOR, OMP_SIMD };
-
-  for (tree ts = ctx; ts; ts = TREE_CHAIN (ts), i--)
-    {
-      enum omp_ts_code sel = OMP_TS_CODE (ts);
-      int j = (int)sel - (int)OMP_TRAIT_CONSTRUCT_TARGET;
-      gcc_assert (j >= 0 && (unsigned int) j < ARRAY_SIZE (code_map));
-      constructs[i] = code_map[j];
-    }
-  gcc_assert (i == -1);
-}
-
 /* Return true if PROP is possibly present in one of the offloading target's
    OpenMP contexts.  The format of PROPS string is always offloading target's
    name terminated by '\0', followed by properties for that offloading
@@ -1671,400 +1646,6 @@ omp_construct_traits_match (tree selector_traits, tree context_traits,
   return true;
 }
 
-#if 0
-/* Return 1 if context selector matches the current OpenMP context, 0
-   if it does not and -1 if it is unknown and need to be determined later.
-   Some properties can be checked right away during parsing (this routine),
-   others need to wait until the whole TU is parsed, others need to wait until
-   IPA, others until vectorization.  */
-
-int
-omp_context_selector_matches (tree ctx)
-{
-  int ret = 1;
-  for (tree tss = ctx; tss; tss = TREE_CHAIN (tss))
-    {
-      enum omp_tss_code set = OMP_TSS_CODE (tss);
-      tree selectors = OMP_TSS_TRAIT_SELECTORS (tss);
-
-      /* Immediately reject the match if there are any ignored
-	 selectors present.  */
-      for (tree ts = selectors; ts; ts = TREE_CHAIN (ts))
-	if (OMP_TS_CODE (ts) == OMP_TRAIT_INVALID)
-	  return 0;
-
-      if (set == OMP_TRAIT_SET_CONSTRUCT)
-	{
-	  /* For now, ignore the construct set.  While something can be
-	     determined already during parsing, we don't know until end of TU
-	     whether additional constructs aren't added through declare variant
-	     unless "omp declare variant variant" attribute exists already
-	     (so in most of the cases), and we'd need to maintain set of
-	     surrounding OpenMP constructs, which is better handled during
-	     gimplification.  */
-	  if (symtab->state == PARSING)
-	    {
-	      ret = -1;
-	      continue;
-	    }
-
-	  int nconstructs = list_length (selectors);
-	  enum tree_code *constructs = NULL;
-	  if (nconstructs)
-	    {
-	      /* Even though this alloca appears in a loop over selector
-		 sets, it does not repeatedly grow the stack, because
-		 there can be only one construct selector set specified.
-		 This is enforced by omp_check_context_selector.  */
-	      constructs
-		= (enum tree_code *) alloca (nconstructs
-					     * sizeof (enum tree_code));
-	      omp_construct_traits_to_codes (selectors, nconstructs,
-					     constructs);
-	    }
-
-	  if (cfun && (cfun->curr_properties & PROP_gimple_any) != 0)
-	    {
-	      if (!cfun->after_inlining)
-		{
-		  ret = -1;
-		  continue;
-		}
-	      int i;
-	      for (i = 0; i < nconstructs; ++i)
-		if (constructs[i] == OMP_SIMD)
-		  break;
-	      if (i < nconstructs)
-		{
-		  ret = -1;
-		  continue;
-		}
-	      /* If there is no simd, assume it is ok after IPA,
-		 constructs should have been checked before.  */
-	      continue;
-	    }
-
-	  int r = omp_construct_selector_matches (constructs, nconstructs,
-						  NULL);
-	  if (r == 0)
-	    return 0;
-	  if (r == -1)
-	    ret = -1;
-	  continue;
-	}
-      for (tree ts = selectors; ts; ts = TREE_CHAIN (ts))
-	{
-	  enum omp_ts_code sel = OMP_TS_CODE (ts);
-	  switch (sel)
-	    {
-	    case OMP_TRAIT_IMPLEMENTATION_VENDOR:
-	      if (set == OMP_TRAIT_SET_IMPLEMENTATION)
-		for (tree p = OMP_TS_PROPERTIES (ts); p; p = TREE_CHAIN (p))
-		  {
-		    const char *prop = omp_context_name_list_prop (p);
-		    if (prop == NULL)
-		      return 0;
-		    if (!strcmp (prop, "gnu"))
-		      continue;
-		    return 0;
-		  }
-	      break;
-	    case OMP_TRAIT_IMPLEMENTATION_EXTENSION:
-	      if (set == OMP_TRAIT_SET_IMPLEMENTATION)
-		/* We don't support any extensions right now.  */
-		return 0;
-	      break;
-	    case OMP_TRAIT_IMPLEMENTATION_ADMO:
-	      if (set == OMP_TRAIT_SET_IMPLEMENTATION)
-		{
-		  if (cfun && (cfun->curr_properties & PROP_gimple_any) != 0)
-		    break;
-
-		  enum omp_memory_order omo
-		    = ((enum omp_memory_order)
-		       (omp_requires_mask
-			& OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER));
-		  if (omo == OMP_MEMORY_ORDER_UNSPECIFIED)
-		    {
-		      /* We don't know yet, until end of TU.  */
-		      if (symtab->state == PARSING)
-			{
-			  ret = -1;
-			  break;
-			}
-		      else
-			omo = OMP_MEMORY_ORDER_RELAXED;
-		    }
-		  tree p = OMP_TS_PROPERTIES (ts);
-		  const char *prop = IDENTIFIER_POINTER (OMP_TP_NAME (p));
-		  if (!strcmp (prop, "relaxed")
-		      && omo != OMP_MEMORY_ORDER_RELAXED)
-		    return 0;
-		  else if (!strcmp (prop, "seq_cst")
-			   && omo != OMP_MEMORY_ORDER_SEQ_CST)
-		    return 0;
-		  else if (!strcmp (prop, "acq_rel")
-			   && omo != OMP_MEMORY_ORDER_ACQ_REL)
-		    return 0;
-		  else if (!strcmp (prop, "acquire")
-			   && omo != OMP_MEMORY_ORDER_ACQUIRE)
-		    return 0;
-		  else if (!strcmp (prop, "release")
-			   && omo != OMP_MEMORY_ORDER_RELEASE)
-		    return 0;
-		}
-	      break;
-	    case OMP_TRAIT_DEVICE_ARCH:
-	      if (set == OMP_TRAIT_SET_DEVICE)
-		for (tree p = OMP_TS_PROPERTIES (ts); p; p = TREE_CHAIN (p))
-		  {
-		    const char *arch = omp_context_name_list_prop (p);
-		    if (arch == NULL)
-		      return 0;
-		    int r = 0;
-		    if (targetm.omp.device_kind_arch_isa != NULL)
-		      r = targetm.omp.device_kind_arch_isa (omp_device_arch,
-							    arch);
-		    if (r == 0 || (r == -1 && symtab->state != PARSING))
-		      {
-			/* If we are or might be in a target region or
-			   declare target function, need to take into account
-			   also offloading values.  */
-			if (!omp_maybe_offloaded ())
-			  return 0;
-			if (ENABLE_OFFLOADING)
-			  {
-			    const char *arches = omp_offload_device_arch;
-			    if (omp_offload_device_kind_arch_isa (arches,
-								  arch))
-			      {
-				ret = -1;
-				continue;
-			      }
-			  }
-			return 0;
-		      }
-		    else if (r == -1)
-		      ret = -1;
-		    /* If arch matches on the host, it still might not match
-		       in the offloading region.  */
-		    else if (omp_maybe_offloaded ())
-		      ret = -1;
-		  }
-	      break;
-	    case OMP_TRAIT_IMPLEMENTATION_UNIFIED_ADDRESS:
-	      if (set == OMP_TRAIT_SET_IMPLEMENTATION)
-		{
-		  if (cfun && (cfun->curr_properties & PROP_gimple_any) != 0)
-		    break;
-
-		  if ((omp_requires_mask & OMP_REQUIRES_UNIFIED_ADDRESS) == 0)
-		    {
-		      if (symtab->state == PARSING)
-			ret = -1;
-		      else
-			return 0;
-		    }
-		}
-	      break;
-	    case OMP_TRAIT_IMPLEMENTATION_UNIFIED_SHARED_MEMORY:
-	      if (set == OMP_TRAIT_SET_IMPLEMENTATION)
-		{
-		  if (cfun && (cfun->curr_properties & PROP_gimple_any) != 0)
-		    break;
-
-		  if ((omp_requires_mask
-		       & OMP_REQUIRES_UNIFIED_SHARED_MEMORY) == 0)
-		    {
-		      if (symtab->state == PARSING)
-			ret = -1;
-		      else
-			return 0;
-		    }
-		}
-	      break;
-	    case OMP_TRAIT_IMPLEMENTATION_SELF_MAPS:
-	      if (set == OMP_TRAIT_SET_IMPLEMENTATION)
-		{
-		  if (cfun && (cfun->curr_properties & PROP_gimple_any) != 0)
-		    break;
-
-		  if ((omp_requires_mask
-		       & OMP_REQUIRES_SELF_MAPS) == 0)
-		    {
-		      if (symtab->state == PARSING)
-			ret = -1;
-		      else
-			return 0;
-		    }
-		}
-	      break;
-	    case OMP_TRAIT_IMPLEMENTATION_DYNAMIC_ALLOCATORS:
-	      if (set == OMP_TRAIT_SET_IMPLEMENTATION)
-		{
-		  if (cfun && (cfun->curr_properties & PROP_gimple_any) != 0)
-		    break;
-
-		  if ((omp_requires_mask
-		       & OMP_REQUIRES_DYNAMIC_ALLOCATORS) == 0)
-		    {
-		      if (symtab->state == PARSING)
-			ret = -1;
-		      else
-			return 0;
-		    }
-		}
-	      break;
-	    case OMP_TRAIT_IMPLEMENTATION_REVERSE_OFFLOAD:
-	      if (set == OMP_TRAIT_SET_IMPLEMENTATION)
-		{
-		  if (cfun && (cfun->curr_properties & PROP_gimple_any) != 0)
-		    break;
-
-		  if ((omp_requires_mask & OMP_REQUIRES_REVERSE_OFFLOAD) == 0)
-		    {
-		      if (symtab->state == PARSING)
-			ret = -1;
-		      else
-			return 0;
-		    }
-		}
-	      break;
-	    case OMP_TRAIT_DEVICE_KIND:
-	      if (set == OMP_TRAIT_SET_DEVICE)
-		for (tree p = OMP_TS_PROPERTIES (ts); p; p = TREE_CHAIN (p))
-		  {
-		    const char *prop = omp_context_name_list_prop (p);
-		    if (prop == NULL)
-		      return 0;
-		    if (!strcmp (prop, "any"))
-		      continue;
-		    if (!strcmp (prop, "host"))
-		      {
-#ifdef ACCEL_COMPILER
-			return 0;
-#else
-			if (omp_maybe_offloaded ())
-			  ret = -1;
-			continue;
-#endif
-		      }
-		    if (!strcmp (prop, "nohost"))
-		      {
-#ifndef ACCEL_COMPILER
-			if (omp_maybe_offloaded ())
-			  ret = -1;
-			else
-			  return 0;
-#endif
-			continue;
-		      }
-		    int r = 0;
-		    if (targetm.omp.device_kind_arch_isa != NULL)
-		      r = targetm.omp.device_kind_arch_isa (omp_device_kind,
-							    prop);
-		    else
-		      r = strcmp (prop, "cpu") == 0;
-		    if (r == 0 || (r == -1 && symtab->state != PARSING))
-		      {
-			/* If we are or might be in a target region or
-			   declare target function, need to take into account
-			   also offloading values.  */
-			if (!omp_maybe_offloaded ())
-			  return 0;
-			if (ENABLE_OFFLOADING)
-			  {
-			    const char *kinds = omp_offload_device_kind;
-			    if (omp_offload_device_kind_arch_isa (kinds, prop))
-			      {
-				ret = -1;
-				continue;
-			      }
-			  }
-			return 0;
-		      }
-		    else if (r == -1)
-		      ret = -1;
-		    /* If kind matches on the host, it still might not match
-		       in the offloading region.  */
-		    else if (omp_maybe_offloaded ())
-		      ret = -1;
-		  }
-	      break;
-	    case OMP_TRAIT_DEVICE_ISA:
-	      if (set == OMP_TRAIT_SET_DEVICE)
-		for (tree p = OMP_TS_PROPERTIES (ts); p; p = TREE_CHAIN (p))
-		  {
-		    const char *isa = omp_context_name_list_prop (p);
-		    if (isa == NULL)
-		      return 0;
-		    int r = 0;
-		    if (targetm.omp.device_kind_arch_isa != NULL)
-		      r = targetm.omp.device_kind_arch_isa (omp_device_isa,
-							    isa);
-		    if (r == 0 || (r == -1 && symtab->state != PARSING))
-		      {
-			/* If isa is valid on the target, but not in the
-			   current function and current function has
-			   #pragma omp declare simd on it, some simd clones
-			   might have the isa added later on.  */
-			if (r == -1
-			    && targetm.simd_clone.compute_vecsize_and_simdlen
-			    && (cfun == NULL || !cfun->after_inlining))
-			  {
-			    tree attrs
-			      = DECL_ATTRIBUTES (current_function_decl);
-			    if (lookup_attribute ("omp declare simd", attrs))
-			      {
-				ret = -1;
-				continue;
-			      }
-			  }
-			/* If we are or might be in a target region or
-			   declare target function, need to take into account
-			   also offloading values.  */
-			if (!omp_maybe_offloaded ())
-			  return 0;
-			if (ENABLE_OFFLOADING)
-			  {
-			    const char *isas = omp_offload_device_isa;
-			    if (omp_offload_device_kind_arch_isa (isas, isa))
-			      {
-				ret = -1;
-				continue;
-			      }
-			  }
-			return 0;
-		      }
-		    else if (r == -1)
-		      ret = -1;
-		    /* If isa matches on the host, it still might not match
-		       in the offloading region.  */
-		    else if (omp_maybe_offloaded ())
-		      ret = -1;
-		  }
-	      break;
-	    case OMP_TRAIT_USER_CONDITION:
-	      if (set == OMP_TRAIT_SET_USER)
-		for (tree p = OMP_TS_PROPERTIES (ts); p; p = TREE_CHAIN (p))
-		  if (OMP_TP_NAME (p) == NULL_TREE)
-		    {
-		      if (integer_zerop (OMP_TP_VALUE (p)))
-			return 0;
-		      if (integer_nonzerop (OMP_TP_VALUE (p)))
-			break;
-		      ret = -1;
-		    }
-	      break;
-	    default:
-	      break;
-	    }
-	}
-    }
-  return ret;
-}
-#endif
-
 /* Return 1 if context selector CTX matches the current OpenMP context, 0
    if it does not and -1 if it is unknown and need to be determined later.
    Some properties can be checked right away during parsing, others need
@@ -3145,79 +2726,6 @@ omp_dynamic_cond (tree ctx, tree supercontext)
     return NULL_TREE;
 }
 
-#if 0
-/* Compute *SCORE for context selector CTX.  Return true if the score
-   would be different depending on whether it is a declare simd clone or
-   not.  DECLARE_SIMD should be true for the case when it would be
-   a declare simd clone.  */
-
-static bool
-omp_context_compute_score (tree ctx, score_wide_int *score, bool declare_simd)
-{
-  tree selectors
-    = omp_get_context_selector_list (ctx, OMP_TRAIT_SET_CONSTRUCT);
-  bool has_kind = omp_get_context_selector (ctx, OMP_TRAIT_SET_DEVICE,
-					    OMP_TRAIT_DEVICE_KIND);
-  bool has_arch = omp_get_context_selector (ctx, OMP_TRAIT_SET_DEVICE,
-					    OMP_TRAIT_DEVICE_ARCH);
-  bool has_isa = omp_get_context_selector (ctx, OMP_TRAIT_SET_DEVICE,
-					   OMP_TRAIT_DEVICE_ISA);
-  bool ret = false;
-  *score = 1;
-  for (tree tss = ctx; tss; tss = TREE_CHAIN (tss))
-    if (OMP_TSS_TRAIT_SELECTORS (tss) != selectors)
-      for (tree ts = OMP_TSS_TRAIT_SELECTORS (tss); ts; ts = TREE_CHAIN (ts))
-	{
-	  tree s = OMP_TS_SCORE (ts);
-	  if (s && TREE_CODE (s) == INTEGER_CST)
-	    *score += score_wide_int::from (wi::to_wide (s),
-					    TYPE_SIGN (TREE_TYPE (s)));
-	}
-
-  if (selectors || has_kind || has_arch || has_isa)
-    {
-      int nconstructs = list_length (selectors);
-      enum tree_code *constructs = NULL;
-      if (nconstructs)
-	{
-	  constructs
-	    = (enum tree_code *) alloca (nconstructs
-					 * sizeof (enum tree_code));
-	  omp_construct_traits_to_codes (selectors, nconstructs, constructs);
-	}
-      int *scores
-	= (int *) alloca ((2 * nconstructs + 2) * sizeof (int));
-      if (omp_construct_selector_matches (constructs, nconstructs, scores)
-	  == 2)
-	ret = true;
-      int b = declare_simd ? nconstructs + 1 : 0;
-      if (scores[b + nconstructs] + 4U < score->get_precision ())
-	{
-	  for (int n = 0; n < nconstructs; ++n)
-	    {
-	      if (scores[b + n] < 0)
-		{
-		  *score = -1;
-		  return ret;
-		}
-	      *score += wi::shifted_mask <score_wide_int> (scores[b + n], 1, false);
-	    }
-	  if (has_kind)
-	    *score += wi::shifted_mask <score_wide_int> (scores[b + nconstructs],
-						     1, false);
-	  if (has_arch)
-	    *score += wi::shifted_mask <score_wide_int> (scores[b + nconstructs] + 1,
-						     1, false);
-	  if (has_isa)
-	    *score += wi::shifted_mask <score_wide_int> (scores[b + nconstructs] + 2,
-						     1, false);
-	}
-      else /* FIXME: Implement this.  */
-	gcc_unreachable ();
-    }
-  return ret;
-}
-#endif
 
 /* Compute *SCORE for context selector CTX, which is already known to match.
    CONSTRUCT_CONTEXT is the OpenMP construct context; if this is null or
@@ -3360,605 +2868,6 @@ omp_complete_construct_context (tree construct_context, bool *completep)
   return construct_context;
 }
 
-/* Class describing a single variant.  */
-struct GTY(()) omp_declare_variant_entry {
-  /* NODE of the variant.  */
-  cgraph_node *variant;
-  /* Score if not in declare simd clone.  */
-  score_wide_int score;
-  /* Score if in declare simd clone.  */
-  score_wide_int score_in_declare_simd_clone;
-  /* Context selector for the variant.  */
-  tree ctx;
-  /* True if the context selector is known to match already.  */
-  bool matches;
-};
-
-/* Class describing a function with variants.  */
-struct GTY((for_user)) omp_declare_variant_base_entry {
-  /* NODE of the base function.  */
-  cgraph_node *base;
-  /* NODE of the artificial function created for the deferred variant
-     resolution.  */
-  cgraph_node *node;
-  /* Vector of the variants.  */
-  vec<omp_declare_variant_entry, va_gc> *variants;
-};
-
-struct omp_declare_variant_hasher
-  : ggc_ptr_hash<omp_declare_variant_base_entry> {
-  static hashval_t hash (omp_declare_variant_base_entry *);
-  static bool equal (omp_declare_variant_base_entry *,
-		     omp_declare_variant_base_entry *);
-};
-
-hashval_t
-omp_declare_variant_hasher::hash (omp_declare_variant_base_entry *x)
-{
-  inchash::hash hstate;
-  hstate.add_int (DECL_UID (x->base->decl));
-  hstate.add_int (x->variants->length ());
-  omp_declare_variant_entry *variant;
-  unsigned int i;
-  FOR_EACH_VEC_SAFE_ELT (x->variants, i, variant)
-    {
-      hstate.add_int (DECL_UID (variant->variant->decl));
-      hstate.add_wide_int (variant->score);
-      hstate.add_wide_int (variant->score_in_declare_simd_clone);
-      hstate.add_ptr (variant->ctx);
-      hstate.add_int (variant->matches);
-    }
-  return hstate.end ();
-}
-
-bool
-omp_declare_variant_hasher::equal (omp_declare_variant_base_entry *x,
-				   omp_declare_variant_base_entry *y)
-{
-  if (x->base != y->base
-      || x->variants->length () != y->variants->length ())
-    return false;
-  omp_declare_variant_entry *variant;
-  unsigned int i;
-  FOR_EACH_VEC_SAFE_ELT (x->variants, i, variant)
-    if (variant->variant != (*y->variants)[i].variant
-	|| variant->score != (*y->variants)[i].score
-	|| (variant->score_in_declare_simd_clone
-	    != (*y->variants)[i].score_in_declare_simd_clone)
-	|| variant->ctx != (*y->variants)[i].ctx
-	|| variant->matches != (*y->variants)[i].matches)
-      return false;
-  return true;
-}
-
-static GTY(()) hash_table<omp_declare_variant_hasher> *omp_declare_variants;
-
-struct omp_declare_variant_alt_hasher
-  : ggc_ptr_hash<omp_declare_variant_base_entry> {
-  static hashval_t hash (omp_declare_variant_base_entry *);
-  static bool equal (omp_declare_variant_base_entry *,
-		     omp_declare_variant_base_entry *);
-};
-
-hashval_t
-omp_declare_variant_alt_hasher::hash (omp_declare_variant_base_entry *x)
-{
-  return DECL_UID (x->node->decl);
-}
-
-bool
-omp_declare_variant_alt_hasher::equal (omp_declare_variant_base_entry *x,
-				       omp_declare_variant_base_entry *y)
-{
-  return x->node == y->node;
-}
-
-static GTY(()) hash_table<omp_declare_variant_alt_hasher>
-  *omp_declare_variant_alt;
-
-#if 0
-/* Try to resolve declare variant after gimplification.  */
-
-static tree
-omp_resolve_late_declare_variant (tree alt)
-{
-  cgraph_node *node = cgraph_node::get (alt);
-  cgraph_node *cur_node = cgraph_node::get (cfun->decl);
-  if (node == NULL
-      || !node->declare_variant_alt
-      || !cfun->after_inlining)
-    return alt;
-
-  omp_declare_variant_base_entry entry;
-  entry.base = NULL;
-  entry.node = node;
-  entry.variants = NULL;
-  omp_declare_variant_base_entry *entryp
-    = omp_declare_variant_alt->find_with_hash (&entry, DECL_UID (alt));
-
-  unsigned int i, j;
-  omp_declare_variant_entry *varentry1, *varentry2;
-  auto_vec <bool, 16> matches;
-  unsigned int nmatches = 0;
-  FOR_EACH_VEC_SAFE_ELT (entryp->variants, i, varentry1)
-    {
-      if (varentry1->matches)
-	{
-	  /* This has been checked to be ok already.  */
-	  matches.safe_push (true);
-	  nmatches++;
-	  continue;
-	}
-      switch (omp_context_selector_matches (varentry1->ctx))
-	{
-	case 0:
-          matches.safe_push (false);
-	  break;
-	case -1:
-	  return alt;
-	default:
-	  matches.safe_push (true);
-	  nmatches++;
-	  break;
-	}
-    }
-
-  if (nmatches == 0)
-    return entryp->base->decl;
-
-  /* A context selector that is a strict subset of another context selector
-     has a score of zero.  */
-  FOR_EACH_VEC_SAFE_ELT (entryp->variants, i, varentry1)
-    if (matches[i])
-      {
-        for (j = i + 1;
-	     vec_safe_iterate (entryp->variants, j, &varentry2); ++j)
-	  if (matches[j])
-	    {
-	      int r = omp_context_selector_compare (varentry1->ctx,
-						    varentry2->ctx);
-	      if (r == -1)
-		{
-		  /* ctx1 is a strict subset of ctx2, ignore ctx1.  */
-		  matches[i] = false;
-		  break;
-		}
-	      else if (r == 1)
-		/* ctx2 is a strict subset of ctx1, remove ctx2.  */
-		matches[j] = false;
-	    }
-      }
-
-  score_wide_int max_score = -1;
-  varentry2 = NULL;
-  FOR_EACH_VEC_SAFE_ELT (entryp->variants, i, varentry1)
-    if (matches[i])
-      {
-	score_wide_int score
-	  = (cur_node->simdclone ? varentry1->score_in_declare_simd_clone
-	     : varentry1->score);
-	if (score > max_score)
-	  {
-	    max_score = score;
-	    varentry2 = varentry1;
-	  }
-      }
-  return varentry2->variant->decl;
-}
-
-/* Hook to adjust hash tables on cgraph_node removal.  */
-
-static void
-omp_declare_variant_remove_hook (struct cgraph_node *node, void *)
-{
-  if (!node->declare_variant_alt)
-    return;
-
-  /* Drop this hash table completely.  */
-  omp_declare_variants = NULL;
-  /* And remove node from the other hash table.  */
-  if (omp_declare_variant_alt)
-    {
-      omp_declare_variant_base_entry entry;
-      entry.base = NULL;
-      entry.node = node;
-      entry.variants = NULL;
-      omp_declare_variant_alt->remove_elt_with_hash (&entry,
-						     DECL_UID (node->decl));
-    }
-}
-
-/* Try to resolve declare variant, return the variant decl if it should
-   be used instead of base, or base otherwise.  */
-
-tree
-omp_resolve_declare_variant (tree base)
-{
-  tree variant1 = NULL_TREE, variant2 = NULL_TREE;
-  if (cfun && (cfun->curr_properties & PROP_gimple_any) != 0)
-    return omp_resolve_late_declare_variant (base);
-
-  auto_vec <tree, 16> variants;
-  auto_vec <bool, 16> defer;
-  bool any_deferred = false;
-  for (tree attr = DECL_ATTRIBUTES (base); attr; attr = TREE_CHAIN (attr))
-    {
-      attr = lookup_attribute ("omp declare variant base", attr);
-      if (attr == NULL_TREE)
-	break;
-      if (TREE_CODE (TREE_PURPOSE (TREE_VALUE (attr))) != FUNCTION_DECL)
-	continue;
-      cgraph_node *node = cgraph_node::get (base);
-      /* If this is already a magic decl created by this function,
-	 don't process it again.  */
-      if (node && node->declare_variant_alt)
-	return base;
-      switch (omp_context_selector_matches (TREE_VALUE (TREE_VALUE (attr))))
-	{
-	case 0:
-	  /* No match, ignore.  */
-	  break;
-	case -1:
-	  /* Needs to be deferred.  */
-	  any_deferred = true;
-	  variants.safe_push (attr);
-	  defer.safe_push (true);
-	  break;
-	default:
-	  variants.safe_push (attr);
-	  defer.safe_push (false);
-	  break;
-	}
-    }
-  if (variants.length () == 0)
-    return base;
-
-  if (any_deferred)
-    {
-      score_wide_int max_score1 = 0;
-      score_wide_int max_score2 = 0;
-      bool first = true;
-      unsigned int i;
-      tree attr1, attr2;
-      omp_declare_variant_base_entry entry;
-      entry.base = cgraph_node::get_create (base);
-      entry.node = NULL;
-      vec_alloc (entry.variants, variants.length ());
-      FOR_EACH_VEC_ELT (variants, i, attr1)
-	{
-	  score_wide_int score1;
-	  score_wide_int score2;
-	  bool need_two;
-	  tree ctx = TREE_VALUE (TREE_VALUE (attr1));
-	  need_two = omp_context_compute_score (ctx, &score1, false);
-	  if (need_two)
-	    omp_context_compute_score (ctx, &score2, true);
-	  else
-	    score2 = score1;
-	  if (first)
-	    {
-	      first = false;
-	      max_score1 = score1;
-	      max_score2 = score2;
-	      if (!defer[i])
-		{
-		  variant1 = attr1;
-		  variant2 = attr1;
-		}
-	    }
-	  else
-	    {
-	      if (max_score1 == score1)
-		variant1 = NULL_TREE;
-	      else if (score1 > max_score1)
-		{
-		  max_score1 = score1;
-		  variant1 = defer[i] ? NULL_TREE : attr1;
-		}
-	      if (max_score2 == score2)
-		variant2 = NULL_TREE;
-	      else if (score2 > max_score2)
-		{
-		  max_score2 = score2;
-		  variant2 = defer[i] ? NULL_TREE : attr1;
-		}
-	    }
-	  omp_declare_variant_entry varentry;
-	  varentry.variant
-	    = cgraph_node::get_create (TREE_PURPOSE (TREE_VALUE (attr1)));
-	  varentry.score = score1;
-	  varentry.score_in_declare_simd_clone = score2;
-	  varentry.ctx = ctx;
-	  varentry.matches = !defer[i];
-	  entry.variants->quick_push (varentry);
-	}
-
-      /* If there is a clear winner variant with the score which is not
-	 deferred, verify it is not a strict subset of any other context
-	 selector and if it is not, it is the best alternative no matter
-	 whether the others do or don't match.  */
-      if (variant1 && variant1 == variant2)
-	{
-	  tree ctx1 = TREE_VALUE (TREE_VALUE (variant1));
-	  FOR_EACH_VEC_ELT (variants, i, attr2)
-	    {
-	      if (attr2 == variant1)
-		continue;
-	      tree ctx2 = TREE_VALUE (TREE_VALUE (attr2));
-	      int r = omp_context_selector_compare (ctx1, ctx2);
-	      if (r == -1)
-		{
-		  /* The winner is a strict subset of ctx2, can't
-		     decide now.  */
-		  variant1 = NULL_TREE;
-		  break;
-		}
-	    }
-	  if (variant1)
-	    {
-	      vec_free (entry.variants);
-	      return TREE_PURPOSE (TREE_VALUE (variant1));
-	    }
-	}
-
-      static struct cgraph_node_hook_list *node_removal_hook_holder;
-      if (!node_removal_hook_holder)
-	node_removal_hook_holder
-	  = symtab->add_cgraph_removal_hook (omp_declare_variant_remove_hook,
-					     NULL);
-
-      if (omp_declare_variants == NULL)
-	omp_declare_variants
-	  = hash_table<omp_declare_variant_hasher>::create_ggc (64);
-      omp_declare_variant_base_entry **slot
-	= omp_declare_variants->find_slot (&entry, INSERT);
-      if (*slot != NULL)
-	{
-	  vec_free (entry.variants);
-	  return (*slot)->node->decl;
-	}
-
-      *slot = ggc_cleared_alloc<omp_declare_variant_base_entry> ();
-      (*slot)->base = entry.base;
-      (*slot)->node = entry.base;
-      (*slot)->variants = entry.variants;
-      tree alt = build_decl (DECL_SOURCE_LOCATION (base), FUNCTION_DECL,
-			     DECL_NAME (base), TREE_TYPE (base));
-      DECL_ARTIFICIAL (alt) = 1;
-      DECL_IGNORED_P (alt) = 1;
-      TREE_STATIC (alt) = 1;
-      tree attributes = DECL_ATTRIBUTES (base);
-      if (lookup_attribute ("noipa", attributes) == NULL)
-	{
-	  attributes = tree_cons (get_identifier ("noipa"), NULL, attributes);
-	  if (lookup_attribute ("noinline", attributes) == NULL)
-	    attributes = tree_cons (get_identifier ("noinline"), NULL,
-				    attributes);
-	  if (lookup_attribute ("noclone", attributes) == NULL)
-	    attributes = tree_cons (get_identifier ("noclone"), NULL,
-				    attributes);
-	  if (lookup_attribute ("no_icf", attributes) == NULL)
-	    attributes = tree_cons (get_identifier ("no_icf"), NULL,
-				    attributes);
-	}
-      DECL_ATTRIBUTES (alt) = attributes;
-      DECL_INITIAL (alt) = error_mark_node;
-      (*slot)->node = cgraph_node::create (alt);
-      (*slot)->node->declare_variant_alt = 1;
-      (*slot)->node->create_reference (entry.base, IPA_REF_ADDR);
-      omp_declare_variant_entry *varentry;
-      FOR_EACH_VEC_SAFE_ELT (entry.variants, i, varentry)
-	(*slot)->node->create_reference (varentry->variant, IPA_REF_ADDR);
-      if (omp_declare_variant_alt == NULL)
-	omp_declare_variant_alt
-	  = hash_table<omp_declare_variant_alt_hasher>::create_ggc (64);
-      *omp_declare_variant_alt->find_slot_with_hash (*slot, DECL_UID (alt),
-						     INSERT) = *slot;
-      return alt;
-    }
-
-  if (variants.length () == 1)
-    return TREE_PURPOSE (TREE_VALUE (variants[0]));
-
-  /* A context selector that is a strict subset of another context selector
-     has a score of zero.  */
-  tree attr1, attr2;
-  unsigned int i, j;
-  FOR_EACH_VEC_ELT (variants, i, attr1)
-    if (attr1)
-      {
-	tree ctx1 = TREE_VALUE (TREE_VALUE (attr1));
-	FOR_EACH_VEC_ELT_FROM (variants, j, attr2, i + 1)
-	  if (attr2)
-	    {
-	      tree ctx2 = TREE_VALUE (TREE_VALUE (attr2));
-	      int r = omp_context_selector_compare (ctx1, ctx2);
-	      if (r == -1)
-		{
-		  /* ctx1 is a strict subset of ctx2, remove
-		     attr1 from the vector.  */
-		  variants[i] = NULL_TREE;
-		  break;
-		}
-	      else if (r == 1)
-		/* ctx2 is a strict subset of ctx1, remove attr2
-		   from the vector.  */
-		variants[j] = NULL_TREE;
-	    }
-      }
-  score_wide_int max_score1 = 0;
-  score_wide_int max_score2 = 0;
-  bool first = true;
-  FOR_EACH_VEC_ELT (variants, i, attr1)
-    if (attr1)
-      {
-	if (variant1)
-	  {
-	    score_wide_int score1;
-	    score_wide_int score2;
-	    bool need_two;
-	    tree ctx;
-	    if (first)
-	      {
-		first = false;
-		ctx = TREE_VALUE (TREE_VALUE (variant1));
-		need_two = omp_context_compute_score (ctx, &max_score1, false);
-		if (need_two)
-		  omp_context_compute_score (ctx, &max_score2, true);
-		else
-		  max_score2 = max_score1;
-	      }
-	    ctx = TREE_VALUE (TREE_VALUE (attr1));
-	    need_two = omp_context_compute_score (ctx, &score1, false);
-	    if (need_two)
-	      omp_context_compute_score (ctx, &score2, true);
-	    else
-	      score2 = score1;
-	    if (score1 > max_score1)
-	      {
-		max_score1 = score1;
-		variant1 = attr1;
-	      }
-	    if (score2 > max_score2)
-	      {
-		max_score2 = score2;
-		variant2 = attr1;
-	      }
-	  }
-	else
-	  {
-	    variant1 = attr1;
-	    variant2 = attr1;
-	  }
-      }
-  /* If there is a disagreement on which variant has the highest score
-     depending on whether it will be in a declare simd clone or not,
-     punt for now and defer until after IPA where we will know that.  */
-  return ((variant1 && variant1 == variant2)
-	  ? TREE_PURPOSE (TREE_VALUE (variant1)) : base);
-}
-#endif
-
-void
-omp_lto_output_declare_variant_alt (lto_simple_output_block *ob,
-				    cgraph_node *node,
-				    lto_symtab_encoder_t encoder)
-{
-  gcc_assert (node->declare_variant_alt);
-
-  omp_declare_variant_base_entry entry;
-  entry.base = NULL;
-  entry.node = node;
-  entry.variants = NULL;
-  omp_declare_variant_base_entry *entryp
-    = omp_declare_variant_alt->find_with_hash (&entry, DECL_UID (node->decl));
-  gcc_assert (entryp);
-
-  int nbase = lto_symtab_encoder_lookup (encoder, entryp->base);
-  gcc_assert (nbase != LCC_NOT_FOUND);
-  streamer_write_hwi_stream (ob->main_stream, nbase);
-
-  streamer_write_hwi_stream (ob->main_stream, entryp->variants->length ());
-
-  unsigned int i;
-  omp_declare_variant_entry *varentry;
-  FOR_EACH_VEC_SAFE_ELT (entryp->variants, i, varentry)
-    {
-      int nvar = lto_symtab_encoder_lookup (encoder, varentry->variant);
-      gcc_assert (nvar != LCC_NOT_FOUND);
-      streamer_write_hwi_stream (ob->main_stream, nvar);
-
-      for (score_wide_int *w = &varentry->score; ;
-	   w = &varentry->score_in_declare_simd_clone)
-	{
-	  unsigned len = w->get_len ();
-	  streamer_write_hwi_stream (ob->main_stream, len);
-	  const HOST_WIDE_INT *val = w->get_val ();
-	  for (unsigned j = 0; j < len; j++)
-	    streamer_write_hwi_stream (ob->main_stream, val[j]);
-	  if (w == &varentry->score_in_declare_simd_clone)
-	    break;
-	}
-
-      HOST_WIDE_INT cnt = -1;
-      HOST_WIDE_INT i = varentry->matches ? 1 : 0;
-      for (tree attr = DECL_ATTRIBUTES (entryp->base->decl);
-	   attr; attr = TREE_CHAIN (attr), i += 2)
-	{
-	  attr = lookup_attribute ("omp declare variant base", attr);
-	  if (attr == NULL_TREE)
-	    break;
-
-	  if (varentry->ctx == TREE_VALUE (TREE_VALUE (attr)))
-	    {
-	      cnt = i;
-	      break;
-	    }
-	}
-
-      gcc_assert (cnt != -1);
-      streamer_write_hwi_stream (ob->main_stream, cnt);
-    }
-}
-
-void
-omp_lto_input_declare_variant_alt (lto_input_block *ib, cgraph_node *node,
-				   vec<symtab_node *> nodes)
-{
-  gcc_assert (node->declare_variant_alt);
-  omp_declare_variant_base_entry *entryp
-    = ggc_cleared_alloc<omp_declare_variant_base_entry> ();
-  entryp->base = dyn_cast<cgraph_node *> (nodes[streamer_read_hwi (ib)]);
-  entryp->node = node;
-  unsigned int len = streamer_read_hwi (ib);
-  vec_alloc (entryp->variants, len);
-
-  for (unsigned int i = 0; i < len; i++)
-    {
-      omp_declare_variant_entry varentry;
-      varentry.variant
-	= dyn_cast<cgraph_node *> (nodes[streamer_read_hwi (ib)]);
-      for (score_wide_int *w = &varentry.score; ;
-	   w = &varentry.score_in_declare_simd_clone)
-	{
-	  unsigned len2 = streamer_read_hwi (ib);
-	  HOST_WIDE_INT arr[WIDE_INT_MAX_HWIS (1024)];
-	  gcc_assert (len2 <= WIDE_INT_MAX_HWIS (1024));
-	  for (unsigned int j = 0; j < len2; j++)
-	    arr[j] = streamer_read_hwi (ib);
-	  *w = score_wide_int::from_array (arr, len2, true);
-	  if (w == &varentry.score_in_declare_simd_clone)
-	    break;
-	}
-
-      HOST_WIDE_INT cnt = streamer_read_hwi (ib);
-      HOST_WIDE_INT j = 0;
-      varentry.ctx = NULL_TREE;
-      varentry.matches = (cnt & 1) ? true : false;
-      cnt &= ~HOST_WIDE_INT_1;
-      for (tree attr = DECL_ATTRIBUTES (entryp->base->decl);
-	   attr; attr = TREE_CHAIN (attr), j += 2)
-	{
-	  attr = lookup_attribute ("omp declare variant base", attr);
-	  if (attr == NULL_TREE)
-	    break;
-
-	  if (cnt == j)
-	    {
-	      varentry.ctx = TREE_VALUE (TREE_VALUE (attr));
-	      break;
-	    }
-	}
-      gcc_assert (varentry.ctx != NULL_TREE);
-      entryp->variants->quick_push (varentry);
-    }
-  if (omp_declare_variant_alt == NULL)
-    omp_declare_variant_alt
-      = hash_table<omp_declare_variant_alt_hasher>::create_ggc (64);
-  *omp_declare_variant_alt->find_slot_with_hash (entryp, DECL_UID (node->decl),
-						 INSERT) = entryp;
-}
-
 /* Comparison function for sorting routines, to sort OpenMP metadirective
    variants by decreasing score.  */
 
@@ -5779,4 +4688,3 @@ omp_maybe_apply_loop_xforms (tree *expr_p, tree for_clauses)
     }
 }
 
-#include "gt-omp-general.h"
diff --git a/gcc/omp-offload.cc b/gcc/omp-offload.cc
index 6681b8e5116..c468de6328c 100644
--- a/gcc/omp-offload.cc
+++ b/gcc/omp-offload.cc
@@ -2701,8 +2701,6 @@ execute_omp_device_lower ()
   bool regimplify = false;
   basic_block bb;
   gimple_stmt_iterator gsi;
-  bool calls_declare_variant_alt
-    = cgraph_node::get (cfun->decl)->calls_declare_variant_alt;
 #ifdef ACCEL_COMPILER
   bool omp_redirect_indirect_calls = vec_safe_length (offload_ind_funcs) > 0;
   tree map_ptr_fn
@@ -2727,8 +2725,6 @@ execute_omp_device_lower ()
 	  continue;
 	if (!gimple_call_internal_p (stmt))
 	  {
-	    /* FIXME: this is a leftover of obsolete code.  */
-	    gcc_assert (!calls_declare_variant_alt);
 #ifdef ACCEL_COMPILER
 	    if (omp_redirect_indirect_calls
 		&& gimple_call_fndecl (stmt) == NULL_TREE)
@@ -2903,9 +2899,7 @@ public:
 #endif
       return (!(fun->curr_properties & PROP_gimple_lomp_dev)
 	      || (flag_openmp
-		  && (node->calls_declare_variant_alt
-		      || node->has_omp_variant_constructs
-		      || offload_ind_funcs_p)));
+		  && (node->has_omp_variant_constructs || offload_ind_funcs_p)));
     }
   unsigned int execute (function *) final override
     {
diff --git a/gcc/omp-simd-clone.cc b/gcc/omp-simd-clone.cc
index befb49c876f..8015da23ae2 100644
--- a/gcc/omp-simd-clone.cc
+++ b/gcc/omp-simd-clone.cc
@@ -689,8 +689,6 @@ simd_clone_create (struct cgraph_node *old_node, bool force_local)
 	 the old node.  */
       new_node->local = old_node->local;
       new_node->externally_visible = old_node->externally_visible;
-      new_node->calls_declare_variant_alt
-	= old_node->calls_declare_variant_alt;
       new_node->has_omp_variant_constructs
 	= old_node->has_omp_variant_constructs;
     }
diff --git a/gcc/passes.cc b/gcc/passes.cc
index d1e6fe3b91a..dd078be0753 100644
--- a/gcc/passes.cc
+++ b/gcc/passes.cc
@@ -2896,8 +2896,7 @@ ipa_write_summaries (void)
     {
       struct cgraph_node *node = order[i];
 
-      if ((node->definition || node->declare_variant_alt)
-	  && node->need_lto_streaming)
+      if (node->definition && node->need_lto_streaming)
 	{
 	  if (gimple_has_body_p (node->decl))
 	    lto_prepare_function_for_streaming (node);
diff --git a/gcc/symtab.cc b/gcc/symtab.cc
index 762a6236ca1..3eadfcfedd4 100644
--- a/gcc/symtab.cc
+++ b/gcc/symtab.cc
@@ -2161,7 +2161,7 @@ symtab_node::get_partitioning_class (void)
   if (DECL_ABSTRACT_P (decl))
     return SYMBOL_EXTERNAL;
 
-  if (cnode && (cnode->inlined_to || cnode->declare_variant_alt))
+  if (cnode && cnode->inlined_to)
     return SYMBOL_DUPLICATE;
 
   /* Transparent aliases are always duplicated.  */
diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
index 09bfe33c9c0..719411494e8 100644
--- a/gcc/tree-inline.cc
+++ b/gcc/tree-inline.cc
@@ -5042,8 +5042,6 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id,
   if (src_properties != prop_mask)
     dst_cfun->curr_properties &= src_properties | ~prop_mask;
   dst_cfun->calls_eh_return |= id->src_cfun->calls_eh_return;
-  id->dst_node->calls_declare_variant_alt
-    |= id->src_node->calls_declare_variant_alt;
   id->dst_node->has_omp_variant_constructs
     |= id->src_node->has_omp_variant_constructs;
 
@@ -6346,8 +6344,6 @@ tree_function_versioning (tree old_decl, tree new_decl,
   DECL_ARGUMENTS (new_decl) = DECL_ARGUMENTS (old_decl);
   initialize_cfun (new_decl, old_decl,
 		   new_entry ? new_entry->count : old_entry_block->count);
-  new_version_node->calls_declare_variant_alt
-    = old_version_node->calls_declare_variant_alt;
   new_version_node->has_omp_variant_constructs
     = old_version_node->has_omp_variant_constructs;
   if (DECL_STRUCT_FUNCTION (new_decl)->gimple_df)
-- 
2.25.1



More information about the Gcc-patches mailing list