https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95583
Bug ID: 95583
Summary: [OpenMP] Offloading – Missed optimization / before LTO
stream out, do more IPA optimizations affecting
host←→target ABI
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Keywords: missed-optimization, openmp
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
Depends on: 95551
Target Milestone: ---
Follow up to PR 95551 + PR 94848 and some other PRs.
Currently, the flow is:
1. ipa_passes (); → calls output_offload_tables, writes LTO for target lto1
(with -flto, stop here and continue with host lto1).
On host compiler or host lto1 compiler – and on target lto1 compiler, do:
2. execute_ipa_pass_list (g->get_passes ()->all_late_ipa_passes);
3. omp_finish_file()
As all_late_ipa_passes runs after writing the output_offload_tables, function
arguments (→ PR92029), inlining, global variable elimination etc. cannot happen
if they affect the host←→target ABI. And adding libgomp calls (e.g. for global
variable mapping) hamper optimizations which could be done otherwise.
Hence, optimizations influencing the host←→target ABI need to be handled before
output_offload_tables.
An example is the test case of PR 95551, where -O3 eliminates the static,
read-only array variable created for a Fortran array constructor but one still
needs to keep it as it is referenced in the output_offload_tables. And as it is
referenced in a complicated way, the local-only variable cannot be eliminated
anymore on the device side either.
Another example is PR90591 where value propagation could be done (and mapping
could be optimized to avoid pointless copyin/copyout or ...).
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95551
[Bug 95551] [OpenMP, OpenACC] -fopenmp/-fopenacc also with -foffload=disable
fails with: (.gnu.offload_vars+0x0): undefined reference to `A.10.2'