https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92029

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.0

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
It means the variable is gone.  I guess it's too late to mark the variable as
force_output where it is currently done.  Maybe do it in
varpool_node::get_create
where we also push it to the offload_vars vector?  I'm not sure if at that
point the variable is used in the IL but only "meta-wise" thus another
fix would be to _not_ stream it into the offload section in
output_offload_tables
if the variable was removed:

diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 147975ba869..481b4a5b45c 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -1076,8 +1076,9 @@ output_offload_tables (void)
     {
       streamer_write_enum (ob->main_stream, LTO_symtab_tags,
                           LTO_symtab_last_tag, LTO_symtab_variable);
-      lto_output_var_decl_index (ob->decl_state, ob->main_stream,
-                                (*offload_vars)[i]);
+      if (varpool_node::get ((*offload_vars)[i]))
+       lto_output_var_decl_index (ob->decl_state, ob->main_stream,
+                                  (*offload_vars)[i]);
     }

   streamer_write_uhwi_stream (ob->main_stream, 0);

I'm also curious why we need to populate offload_vars during varpool node
creation time rather than when streaming the offload portion.  IPA
references should allow to identify those that need streaming?

But that's a larger re-org.

That said, the change just exposed a latent issue - a variable being optimized
away between putting it into offload_vars and streaming out.

Reply via email to