Sergio Afonso 1e4b4fa1b2
[Flang][OpenMP] Minimize host ops remaining in device compilation (#137200)
This patch updates the function filtering OpenMP pass intended to remove
host functions from the MLIR module created by Flang lowering when
targeting an OpenMP target device.

Host functions holding target regions must be kept, so that the target
regions within them can be translated for the device. The issue is that
non-target operations inside these functions cannot be discarded because
some of them hold information that is also relevant during target device
codegen. Specifically, mapping information resides outside of
`omp.target` regions.

This patch updates the previous behavior where all host operations were
preserved to then ignore all of those that are not actually needed by
target device codegen. This, in practice, means only keeping target
regions and mapping information needed by the device. Arguments for some
of these remaining operations are replaced by placeholder allocations
and `fir.undefined`, since they are only actually defined inside of the
target regions themselves.

As a result, this set of changes makes it possible to later simplify
target device codegen, as it is no longer necessary to handle host
operations differently to avoid issues.
2026-01-29 12:44:00 +00:00
..