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 PR63868 - Guard offloading with ifdef ENABLE_OFFLOADING


Hi,

This patch disables the generation of sections with offload IR and offload
tables by default, when a compiler is configured without
--enable-offload-targets= .
Bootsrap and regtesting in progress, OK after it finished?

  -- Ilya


	PR regression/63868
gcc/
	* cgraph.c (cgraph_node::create): Guard g->have_offload with
	ifdef ENABLE_OFFLOADING.
	* omp-low.c (create_omp_child_function): Likewise.
	(expand_omp_target): Guard node and offload_funcs
	with ifdef ENABLE_OFFLOADING.
	* varpool.c (varpool_node::get_create): Guard g->have_offload and
	offload_vars with ifdef ENABLE_OFFLOADING.


diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index cc04744..18ae6a8 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -500,7 +500,9 @@ cgraph_node::create (tree decl)
       && lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl)))
     {
       node->offloadable = 1;
+#ifdef ENABLE_OFFLOADING
       g->have_offload = true;
+#endif
     }
 
   node->register_symbol ();
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 915d55f..44ce479 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -1961,7 +1961,9 @@ create_omp_child_function (omp_context *ctx, bool task_copy)
 	if (is_targetreg_ctx (octx))
 	  {
 	    cgraph_node::get_create (decl)->offloadable = 1;
+#ifdef ENABLE_OFFLOADING
 	    g->have_offload = true;
+#endif
 	    break;
 	  }
     }
@@ -8287,7 +8289,9 @@ expand_omp_target (struct omp_region *region)
   if (kind == GF_OMP_TARGET_KIND_REGION)
     {
       unsigned srcidx, dstidx, num;
+#ifdef ENABLE_OFFLOADING
       struct cgraph_node *node;
+#endif
 
       /* If the target region needs data sent from the parent
 	 function, then the very first statement (except possible
@@ -8414,18 +8418,22 @@ expand_omp_target (struct omp_region *region)
       DECL_STRUCT_FUNCTION (child_fn)->curr_properties = cfun->curr_properties;
       cgraph_node::add_new_function (child_fn, true);
 
+#ifdef ENABLE_OFFLOADING
       /* Add the new function to the offload table.  */
       vec_safe_push (offload_funcs, child_fn);
+#endif
 
       /* Fix the callgraph edges for child_cfun.  Those for cfun will be
 	 fixed in a following pass.  */
       push_cfun (child_cfun);
       cgraph_edge::rebuild_edges ();
 
+#ifdef ENABLE_OFFLOADING
       /* Prevent IPA from removing child_fn as unreachable, since there are no
 	 refs from the parent function to child_fn in offload LTO mode.  */
       node = cgraph_node::get (child_fn);
       node->mark_force_output ();
+#endif
 
       /* Some EH regions might become dead, see PR34608.  If
 	 pass_cleanup_cfg isn't the first pass to happen with the
@@ -12502,7 +12510,7 @@ omp_finish_file (void)
 
       varpool_node::finalize_decl (vars_decl);
       varpool_node::finalize_decl (funcs_decl);
-   }
+    }
   else
     {
       for (unsigned i = 0; i < num_funcs; i++)
diff --git a/gcc/varpool.c b/gcc/varpool.c
index 80dd496..50f2e6e 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -171,9 +171,11 @@ varpool_node::get_create (tree decl)
       && lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl)))
     {
       node->offloadable = 1;
+#ifdef ENABLE_OFFLOADING
       g->have_offload = true;
       if (!in_lto_p)
 	vec_safe_push (offload_vars, decl);
+#endif
     }
 
   node->register_symbol ();


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