Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Flang][OpenMP] Lower host_eval clauses during target lowering
Previously, the approach taken to deal with host-evaluated clauses for operations nested inside of `omp.target` was to use the `HostClausesInsertionGuard`. This class moved the MLIR insertion point outside the `omp.target` operation, so that clause lowering would produce code to be evaluated in the host device. However, this approach resulted in the use of MLIR values defined only inside of the target region outside of it. Then, some fix-up work was performed to replace these uses with the equivalent values outside, which had to consider multiple corner cases based on the types and the origin of these values. This patch replaces that approach with another in which these host-evaluated clauses are lowered as part of the processing of `omp.target` clauses, so the created MLIR operations are correct from the beginning, without the need for a fix-up pass. For that, evaluations related to a target construct are analyzed and processed independently of the established lowering process, also checking nested evaluations for the code patterns for which `host_eval` operands have to be introduced for the `omp.target` operation under construction. If one of these patterns is found, the relevant clauses are evaluated and stored in a global structure. This global structure is checked and used when lowering clauses for operations that can potentially be evaluated in the host, rather than immediately prior to that operation. If it has already been evaluated in the host, the corresponding `omp.target` region block argument is passed as an operand to that operation. Otherwise, it is evaluated as usual.
- Loading branch information