Kiran Chandramohan dd32bf9a77 [Flang,MLIR,OpenMP] Fix a few tests that were not converting to LLVM
A few OpenMP tests were retaining the FIR operands even after running
the LLVM conversion pass. To fix these tests the legality checkes for
OpenMP conversion are made stricter to include operands and results.
The Flush, Single and Sections operations are added to conversions or
legality checks. The RegionLessOpConversion is appropriately renamed
to clarify that it works only for operations with Variable operands.
The operands of the flush operation are changed to match those of
Variable Operands.

Fix for an OpenMP issue mentioned in
https://github.com/llvm/llvm-project/issues/55210.

Reviewed By: shraiysh, peixin, awarzynski

Differential Revision: https://reviews.llvm.org/D127092
2022-06-07 09:55:53 +00:00

70 lines
2.5 KiB
Fortran

!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s --check-prefixes="FIRDialect,OMPDialect"
!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | fir-opt --cfg-conversion | fir-opt --fir-to-llvm-ir | FileCheck %s --check-prefixes="LLVMDialect,OMPDialect"
!===============================================================================
! Single construct
!===============================================================================
!FIRDialect-LABEL: func @_QPomp_single
!FIRDialect-SAME: (%[[x:.*]]: !fir.ref<i32> {fir.bindc_name = "x"})
subroutine omp_single(x)
integer, intent(inout) :: x
!OMPDialect: omp.parallel
!$omp parallel
!OMPDialect: omp.single
!$omp single
!FIRDialect: %[[xval:.*]] = fir.load %[[x]] : !fir.ref<i32>
!FIRDialect: %[[res:.*]] = arith.addi %[[xval]], %{{.*}} : i32
!FIRDialect: fir.store %[[res]] to %[[x]] : !fir.ref<i32>
x = x + 12
!OMPDialect: omp.terminator
!$omp end single
!OMPDialect: omp.terminator
!$omp end parallel
end subroutine omp_single
!===============================================================================
! Single construct with nowait
!===============================================================================
!FIRDialect-LABEL: func @_QPomp_single_nowait
!FIRDialect-SAME: (%[[x:.*]]: !fir.ref<i32> {fir.bindc_name = "x"})
subroutine omp_single_nowait(x)
integer, intent(inout) :: x
!OMPDialect: omp.parallel
!$omp parallel
!OMPDialect: omp.single nowait
!$omp single
!FIRDialect: %[[xval:.*]] = fir.load %[[x]] : !fir.ref<i32>
!FIRDialect: %[[res:.*]] = arith.addi %[[xval]], %{{.*}} : i32
!FIRDialect: fir.store %[[res]] to %[[x]] : !fir.ref<i32>
x = x + 12
!OMPDialect: omp.terminator
!$omp end single nowait
!OMPDialect: omp.terminator
!$omp end parallel
end subroutine omp_single_nowait
!===============================================================================
! Single construct with allocate
!===============================================================================
!FIRDialect-LABEL: func @_QPsingle_allocate
subroutine single_allocate()
use omp_lib
integer :: x
!OMPDialect: omp.parallel {
!$omp parallel
!OMPDialect: omp.single allocate(
!FIRDialect: %{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>
!LLVMDialect: %{{.+}} : i32 -> %{{.+}} : !llvm.ptr<i32>
!OMPDialect: ) {
!$omp single allocate(omp_high_bw_mem_alloc: x) private(x)
!FIRDialect: arith.addi
x = x + 12
!OMPDialect: omp.terminator
!$omp end single
!OMPDialect: omp.terminator
!$omp end parallel
end subroutine single_allocate