https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80411
Bug ID: 80411 Summary: DCE vs. offloading Product: gcc Version: unknown Status: UNCONFIRMED Keywords: openacc, openmp Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: tschwinge at gcc dot gnu.org CC: jakub at gcc dot gnu.org Target Milestone: --- Created attachment 41187 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41187&action=edit dce-vs-offloading.c With "-O1" and higher, and "-fopenacc" or "-fopenmp", different passes (see below) that optimize away dead code, remove the libgomp calls to invoke the offloaded functions. But: the latter ones are still being referenced later on (have not yet worked on figuring out, why/where exactly), and then things explode: With "-foffload=disable": /tmp/ccXNDvkg.o:(.gnu.offload_funcs+0x0): undefined reference to `main._omp_fn.0' /tmp/ccXNDvkg.o:(.gnu.offload_funcs+0x8): undefined reference to `main._omp_fn.1' collect2: error: ld returned 1 exit status With "-foffload=nvptx-none": lto1: internal compiler error: Segmentation fault 0x104a7f93 crash_signal [...]/gcc/toplev.c:333 0x1037bdc8 input_offload_tables [...]/gcc/lto-cgraph.c:2024 0x1037bdc8 input_offload_data(bool) [...]/gcc/lto-cgraph.c:1932 0x1005ba93 read_cgraph_and_symbols [...]/gcc/lto/lto.c:2861 0x1005ba93 lto_main() [...]/gcc/lto/lto.c:3341 On trunk as of r246724, can use "-O2 -fno-tree-ccp -fno-tree-forwprop -fno-tree-fre -fno-tree-vrp" to make this compile/link.