On Mon, Jun 08, 2020 at 12:44:31PM +0200, Tobias Burnus wrote: > As side-remark or follow up: I have also experimented > with the attached patch. > > On the host side, the omp_finish_file call in toplev.c comes > late enough that the the variables is gone and one no longer > writes it to the var table. > > However, the write_lto() → output_offload_tables() call is > that early that both the offload table and the variable is > still written. – Hence, this patch fails at run time as > the two tables host_table & target_data have a different size.
I think this patch is the right thing to do, just needs to be slightly extended. If we do the decision at output_offload_tables, then for the vars we choose to keep in the tables, we should set node->force_output, so that from that point on we don't try to optimize it away. Similarly with functions. Jakub