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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #2)
> 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
…
> +      if (varpool_node::get ((*offload_vars)[i]))

At least that's not sufficient as it then fails at:

#0  0x000000000063b6e8 in vec<tree_node*, va_gc, vl_embed>::operator[]
(this=0x0, ix=0) at gcc-mainline/gcc/vec.h:859
859       gcc_checking_assert (ix < m_vecpfx.m_num);

Note the "this=0x0"; ix is 0.

Called via:
lto-streamer.h:1242| DEFINE_DECL_STREAM_FUNCS (VAR_DECL, var_decl)
lto-streamer.h:124 | if (varpool_node::get ((*offload_vars)[i]))
lto-cgraph.c:1781  |  lto_file_decl_data_get_var_decl (file_data, decl_index);
lto-common.c:2797  | input_offload_tables (!flag_ltrans);

lto_file_decl_data_get_var_decl uses:
  struct lto_in_decl_state *state = data->current_decl_state; \
   return (*state->streams[LTO_DECL_STREAM_## UPPER_NAME])[idx]; \
and we have "idx = 0" and:
 *file_data->current_decl_state
$8 = {streams = {0x0, 0x0, 0x7ffff73eb500, 0x0, 0x0, 0x0, 0x0}, fn_decl = 0x0,
compressed = true}

Reply via email to