Issue 180503
Summary [OpenMP][Flang] LowerWorkDistribute emits 'omp.target_data', triggering translation error
Labels flang
Assignees
Reporter mooxiu
    ## Summary

In [OpenMPToLLVMIRTranslation](https://github.com/llvm/llvm-project/blob/964651ad515b61df56ce51cdc9978b2bcc8d0a7b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp#L7087-L7098), operations like `omp.target_data` are supposed to have already been lowered and not included. (related Issue: https://github.com/llvm/llvm-project/pull/137201)

However, in [LowerWorkdistribute](https://github.com/llvm/llvm-project/blob/964651ad515b61df56ce51cdc9978b2bcc8d0a7b/flang/lib/Optimizer/OpenMP/LowerWorkdistribute.cpp#L753), `omp.target_data` operation could be created again, the above assertion would fail.

## Simple Test Case:

```fortran
program test
  implicit none

  integer, parameter :: N = 42
  double precision, dimension(:), allocatable :: x

  allocate(x(N))
  x = 0

  !$omp target data map(tofrom:x)
  !$omp target teams workdistribute
  x = x
  !$omp end target teams workdistribute
  !$omp end target data

  deallocate(x)
end program test
```

### Error Message
```
warning: OpenMP support for version 60 in flang is still incomplete
warning: OpenMP support for version 60 in flang is still incomplete
loc("{FilePath}.f90":11:9): error: 'omp.target_data' op unsupported host op found in device
loc("{FilePath}.f90":11:9): error: LLVM Translation failed for operation: omp.target_data
error: failed to create the LLVM module
```

## Environment
```
LLVM Version: Latest main (commit: f0a4a91f1b49d77fe28d71363eed02dd8b9003e2)
Target: NVPTX / OpenMP Offloading
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to