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]

Re: [PING][PATCH] Mark symbols in offload tables with force_output in read_offload_tables


On 25/01/16 14:27, Ilya Verbin wrote:
Hi!

On Tue, Jan 05, 2016 at 15:56:15 +0100, Tom de Vries wrote:
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 62e5454..cdaee41 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -1911,6 +1911,11 @@ input_offload_tables (void)
  	      tree fn_decl
  		= lto_file_decl_data_get_fn_decl (file_data, decl_index);
  	      vec_safe_push (offload_funcs, fn_decl);
+
+	      /* Prevent IPA from removing fn_decl as unreachable, since there
+		 may be no refs from the parent function to child_fn in offload
+		 LTO mode.  */
+	      cgraph_node::get (fn_decl)->mark_force_output ();
  	    }
  	  else if (tag == LTO_symtab_variable)
  	    {
@@ -1918,6 +1923,10 @@ input_offload_tables (void)
  	      tree var_decl
  		= lto_file_decl_data_get_var_decl (file_data, decl_index);
  	      vec_safe_push (offload_vars, var_decl);
+
+	      /* Prevent IPA from removing var_decl as unused, since there
+		 may be no refs to var_decl in offload LTO mode.  */
+	      varpool_node::get (var_decl)->force_output = 1;
  	    }

This doesn't work when there is more than one LTO partition, because only first
partition contains full offload table to maintain correct order, but cgraph and
varpool nodes aren't necessarily created for the first partition.  To reproduce:

$ make check-target-libgomp RUNTESTFLAGS="c.exp=for-* --target_board=unix/-flto"
FAIL: libgomp.c/for-3.c (internal compiler error)
FAIL: libgomp.c/for-5.c (internal compiler error)
FAIL: libgomp.c/for-6.c (internal compiler error)
$ make check-target-libgomp RUNTESTFLAGS="c++.exp=for-* --target_board=unix/-flto"
FAIL: libgomp.c++/for-11.C (internal compiler error)
FAIL: libgomp.c++/for-13.C (internal compiler error)
FAIL: libgomp.c++/for-14.C (internal compiler error)

This works for me.

OK for trunk?

Thanks,
- Tom

Check that cgraph/varpool_node exists before use in input_offload_tables

2016-01-26  Tom de Vries  <tom@codesourcery.com>

	* lto-cgraph.c (input_offload_tables): Check that cgraph/varpool_node
	exists before use.

---
 gcc/lto-cgraph.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 0634779..f4bcbaa 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -1915,7 +1915,9 @@ input_offload_tables (void)
 	      /* Prevent IPA from removing fn_decl as unreachable, since there
 		 may be no refs from the parent function to child_fn in offload
 		 LTO mode.  */
-	      cgraph_node::get (fn_decl)->mark_force_output ();
+	      cgraph_node *node = cgraph_node::get (fn_decl);
+	      if (node)
+		node->mark_force_output ();
 	    }
 	  else if (tag == LTO_symtab_variable)
 	    {
@@ -1926,7 +1928,9 @@ input_offload_tables (void)
 
 	      /* Prevent IPA from removing var_decl as unused, since there
 		 may be no refs to var_decl in offload LTO mode.  */
-	      varpool_node::get (var_decl)->force_output = 1;
+	      varpool_node *node = varpool_node::get (var_decl);
+	      if (node)
+		node->force_output = 1;
 	    }
 	  else
 	    fatal_error (input_location,

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