https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92854
--- Comment #6 from jules at gcc dot gnu.org --- Created attachment 47453 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47453&action=edit Patch for acc_map_data-device_already-3.c problem This patch fixes the acc_map_data-device_already-3.c problem, which I guess has probably been broken forever. The single tgt_mem_desc used for all the function and global variable mappings (created in gomp_load_image_to_device) does not have its tgt_start and tgt_end fields set properly, so oacc-mem.c:lookup_dev cannot find any global variable. We can fix this by calculating the total address range covered by (the union of) all offloaded functions and global variables, and set tgt_start and tgt_end appropriately. We then go through each splay tree key's tgt_offset, and adjust it to be an offset within that range. I've yet to run full tests with this, but it works for the test case mentioned.