OpenMP: Fix implicit declare target behavior for host offloading
Corrects OpenMP's handling of 'device_type(host)' in target regions to prevent unintended device code generation.
This change fixes a bug in OpenMP’s handling of target regions that use ‘device_type(host)’ or ‘device(ancestor:1)’. Previously, device code could still be generated in these cases. The fix adjusts the condition in omp_discover_declare_target_tgt_fn_r to ensure that no device code is generated when the host is explicitly targeted, aligning with the intended behavior and resolving a failing test case.
In Details
The commit corrects the conditional logic in omp_offload.cc for handling declare target directives when device_type(host) or device(ancestor:1) is specified. The function omp_discover_declare_target_tgt_fn_r previously used an incorrect condition, leading to device code generation when it should have been suppressed. This fix ensures the walk_subtrees flag is correctly managed, preventing offload code generation for host-targeted regions.