[Mlir-commits] [flang] [mlir] [flang][OpenMP] Ignore DECLARE_SIMD and warn about missing implementa… (PR #232712)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Oct 16 05:16:01 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-openmp
Author: Krzysztof Parzyszek (kparzysz)
<details>
<summary>Changes</summary>
…tion
DECLARE_SIMD is a hint to the compiler and ignoring it is technically speaking a conforming implementation (although obviously not desirable). Do not abort compilation when DECLARE_SIMD is encountered, but emit a warning that it's currently ignored.
---
Full diff: https://github.com/llvm/llvm-project/pull/232712.diff
14 Files Affected:
- (modified) flang/lib/Semantics/check-omp-structure.cpp (+4)
- (modified) flang/test/Semantics/OpenMP/cray-pointer-usage.f90 (+1)
- (modified) flang/test/Semantics/OpenMP/declarative-directive01.f90 (+2)
- (modified) flang/test/Semantics/OpenMP/declare-simd-empty.f90 (+2)
- (modified) flang/test/Semantics/OpenMP/declare-simd-interface-body.f90 (+5-1)
- (modified) flang/test/Semantics/OpenMP/declare-simd-scope.f90 (+12)
- (modified) flang/test/Semantics/OpenMP/declare-simd-uniform.f90 (+2)
- (modified) flang/test/Semantics/OpenMP/declare-simd.f90 (+6-1)
- (modified) flang/test/Semantics/OpenMP/future-directive-spellings.f90 (+1)
- (modified) flang/test/Semantics/OpenMP/linear-clause01.f90 (+9)
- (modified) flang/test/Semantics/OpenMP/linear-clause02.f90 (+3)
- (modified) flang/test/Semantics/OpenMP/linear-clause03.f90 (+1)
- (modified) flang/test/Semantics/OpenMP/simd-linear-array.f90 (+1)
- (modified) mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp (+7)
``````````diff
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 07c9a5222883c..e5b0433ef0220 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -2201,6 +2201,10 @@ void OmpStructureChecker::Enter(const parser::OmpDeclareSimdDirective &x) {
llvm::omp::Version version{context_.langOptions().getOpenMPVersion()};
+ context_.Say(dirName.source,
+ "%s directive is not implemented yet and will be ignored"_warn_en_US,
+ GetUpperName(dirName.v, version));
+
const Scope &containingScope = context_.FindScope(dirName.source);
const Scope &progUnitScope = GetProgramUnitContaining(containingScope);
diff --git a/flang/test/Semantics/OpenMP/cray-pointer-usage.f90 b/flang/test/Semantics/OpenMP/cray-pointer-usage.f90
index 025d339ec8174..8a1b1f0ec90ec 100644
--- a/flang/test/Semantics/OpenMP/cray-pointer-usage.f90
+++ b/flang/test/Semantics/OpenMP/cray-pointer-usage.f90
@@ -4,6 +4,7 @@ subroutine test_cray_pointer_usage
integer :: i
real(8) :: var(*), pointee(2)
pointer(ivar, var)
+ ! WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
! ERROR: Cray Pointee 'var' may not appear in LINEAR clause
! ERROR: List item 'var' in LINEAR clause must be a scalar variable
! ERROR: The list item 'var' specified without the REF 'linear-modifier' must be of INTEGER type
diff --git a/flang/test/Semantics/OpenMP/declarative-directive01.f90 b/flang/test/Semantics/OpenMP/declarative-directive01.f90
index 9e0612b5c8b53..d1ecbf1844944 100644
--- a/flang/test/Semantics/OpenMP/declarative-directive01.f90
+++ b/flang/test/Semantics/OpenMP/declarative-directive01.f90
@@ -21,6 +21,7 @@ end subroutine requires_2
subroutine declare_simd_1(a, b)
real(8), intent(inout) :: a, b
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!ERROR: 'a' in ALIGNED clause must be of type C_PTR, POINTER or ALLOCATABLE
!$omp declare simd(declare_simd_1) aligned(a)
a = 3.14 + b
@@ -38,6 +39,7 @@ end module m1
subroutine declare_simd_2
use m1
procedure (sub) sub1
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!ERROR: INBRANCH and NOTINBRANCH clauses are mutually exclusive and may not appear on the same DECLARE SIMD directive
!$omp declare simd(sub1) inbranch notinbranch
procedure (sub), pointer::p
diff --git a/flang/test/Semantics/OpenMP/declare-simd-empty.f90 b/flang/test/Semantics/OpenMP/declare-simd-empty.f90
index 11aaa8ffc54f0..15e1a61ba08f0 100644
--- a/flang/test/Semantics/OpenMP/declare-simd-empty.f90
+++ b/flang/test/Semantics/OpenMP/declare-simd-empty.f90
@@ -3,6 +3,8 @@
! The directive is in the specification part of a main program, which is not a
! subroutine subprogram, function subprogram, or interface body.
+
+!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!ERROR: DECLARE SIMD directive must appear in the specification part of a subroutine subprogram, function subprogram, or interface body
!$omp declare simd
integer :: x
diff --git a/flang/test/Semantics/OpenMP/declare-simd-interface-body.f90 b/flang/test/Semantics/OpenMP/declare-simd-interface-body.f90
index 624afa8852f2e..7a8553be41219 100644
--- a/flang/test/Semantics/OpenMP/declare-simd-interface-body.f90
+++ b/flang/test/Semantics/OpenMP/declare-simd-interface-body.f90
@@ -6,12 +6,14 @@
interface
subroutine add2(i)
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!WARNING: 'DECLARE SIMD' directive in an interface body has no effect [-Wopenmp-usage]
!$omp declare simd(add2) linear(i:1)
integer :: i
end subroutine
subroutine add3(i)
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!WARNING: 'DECLARE SIMD' directive in an interface body has no effect [-Wopenmp-usage]
!$omp declare simd
integer :: i
@@ -20,8 +22,10 @@ subroutine add3(i)
contains
-! A DECLARE SIMD in an actual definition is fine and must not warn.
+! A DECLARE SIMD in an actual definition is fine and must not warn about
+! its effect.
subroutine sub(i)
+!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!$omp declare simd(sub) linear(i:1)
integer :: i
i = i + 1
diff --git a/flang/test/Semantics/OpenMP/declare-simd-scope.f90 b/flang/test/Semantics/OpenMP/declare-simd-scope.f90
index 64870cd79f42c..a53ffe7f31100 100644
--- a/flang/test/Semantics/OpenMP/declare-simd-scope.f90
+++ b/flang/test/Semantics/OpenMP/declare-simd-scope.f90
@@ -8,9 +8,11 @@
module m
procedure() :: ext
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!ERROR: DECLARE_SIMD directive must appear in the specification part of a subroutine subprogram, function subprogram, or interface body
!$omp declare simd
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!ERROR: DECLARE_SIMD directive must appear in the specification part of a subroutine subprogram, function subprogram, or interface body
!$omp declare_simd(ext)
@@ -19,6 +21,7 @@ module m
! Ok: module subprogram.
subroutine mod_sub(i)
integer :: i
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!$omp declare simd(mod_sub) linear(i:1)
i = i + 1
end subroutine
@@ -26,12 +29,14 @@ subroutine mod_sub(i)
! Ok: module function.
integer function mod_fun(i)
integer :: i
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!$omp declare_simd
mod_fun = i
end function
end module
submodule (m) sm
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!ERROR: DECLARE_SIMD directive must appear in the specification part of a subroutine subprogram, function subprogram, or interface body
!$omp declare simd
end submodule
@@ -39,12 +44,14 @@ integer function mod_fun(i)
block data bd
integer :: x
common /blk/ x
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!ERROR: DECLARE_SIMD directive must appear in the specification part of a subroutine subprogram, function subprogram, or interface body
!$omp declare simd
data x /0/
end block data
program main
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!ERROR: DECLARE_SIMD directive must appear in the specification part of a subroutine subprogram, function subprogram, or interface body
!$omp declare simd
end program
@@ -54,6 +61,7 @@ program main
subroutine in_block(i)
integer :: i
block
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!ERROR: DECLARE_SIMD directive must appear in the specification part of a subroutine subprogram, function subprogram, or interface body
!$omp declare simd
i = i + 1
@@ -63,6 +71,7 @@ subroutine in_block(i)
! Ok: external subroutine.
subroutine ext_sub(i)
integer :: i
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!$omp declare simd(ext_sub) linear(i:1)
i = i + 1
end subroutine
@@ -70,12 +79,14 @@ subroutine ext_sub(i)
! Ok: external function, with an internal subprogram.
integer function ext_fun(i)
integer :: i
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!$omp declare simd(ext_fun)
ext_fun = inner(i)
contains
! Ok: internal subprogram.
integer function inner(j)
integer :: j
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!$omp declare simd(inner) linear(j:1)
inner = j
end function
@@ -85,6 +96,7 @@ integer function inner(j)
subroutine has_interface
interface
subroutine iface_sub(i)
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!WARNING: 'DECLARE SIMD' directive in an interface body has no effect [-Wopenmp-usage]
!$omp declare simd(iface_sub) linear(i:1)
integer :: i
diff --git a/flang/test/Semantics/OpenMP/declare-simd-uniform.f90 b/flang/test/Semantics/OpenMP/declare-simd-uniform.f90
index 1ca18a98976e3..f63892c8fb996 100644
--- a/flang/test/Semantics/OpenMP/declare-simd-uniform.f90
+++ b/flang/test/Semantics/OpenMP/declare-simd-uniform.f90
@@ -3,6 +3,7 @@
! Test declare simd with uniform clause
function add2(a,b,i,fact,alc) result(c)
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!$omp declare simd(add2) uniform(a,b,fact)
integer :: i
integer,pointer::alc
@@ -27,6 +28,7 @@ function bad_uniform(a,b,i) result(c)
double precision :: a(*), b(*), c
integer :: i
double precision :: local
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!ERROR: Variable 'local' in UNIFORM clause must be a dummy argument of the enclosing procedure
!$omp declare simd(bad_uniform) uniform(a,local)
c = a(i) + b(i) + local
diff --git a/flang/test/Semantics/OpenMP/declare-simd.f90 b/flang/test/Semantics/OpenMP/declare-simd.f90
index 2e98f79dbe73b..45c049ddf6aff 100644
--- a/flang/test/Semantics/OpenMP/declare-simd.f90
+++ b/flang/test/Semantics/OpenMP/declare-simd.f90
@@ -5,28 +5,33 @@ module m
integer :: x
! A DECLARE_SIMD directive cannot appear in the specification part of a module.
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!ERROR: DECLARE_SIMD directive must appear in the specification part of a subroutine subprogram, function subprogram, or interface body
!$omp declare_simd(f00)
contains
subroutine f00
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!ERROR: The name 'x' should refer to a procedure
!$omp declare_simd(x)
end
subroutine f01
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!ERROR: DECLARE_SIMD directive should have at most one argument
!$omp declare_simd(f00, f01)
end
subroutine f02
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!ERROR: The argument to the DECLARE_SIMD directive should be a procedure name
!$omp declare_simd(v : integer)
end
integer function f03
-!Ok, expect no diagnostics
+!Ok, expect no errors
+!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
!$omp declare_simd(f03)
end
diff --git a/flang/test/Semantics/OpenMP/future-directive-spellings.f90 b/flang/test/Semantics/OpenMP/future-directive-spellings.f90
index b7705ddd95c4a..8445bef52ebb1 100644
--- a/flang/test/Semantics/OpenMP/future-directive-spellings.f90
+++ b/flang/test/Semantics/OpenMP/future-directive-spellings.f90
@@ -41,6 +41,7 @@ subroutine f02
end
subroutine f03
+!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!WARNING: Directive spelling 'DECLARE_SIMD' is introduced in a later OpenMP version, try -fopenmp-version=60
!$omp declare_simd
end
diff --git a/flang/test/Semantics/OpenMP/linear-clause01.f90 b/flang/test/Semantics/OpenMP/linear-clause01.f90
index dd10ceaf669ff..8ebc5830cbfe8 100644
--- a/flang/test/Semantics/OpenMP/linear-clause01.f90
+++ b/flang/test/Semantics/OpenMP/linear-clause01.f90
@@ -21,11 +21,13 @@ subroutine linear_clause_02(arg_01, arg_02)
!ERROR: The list item 'arg_01' specified without the REF 'linear-modifier' must be of INTEGER type
!ERROR: List item 'arg_01' in LINEAR clause must be a scalar variable
!WARNING: The 'modifier(<list>)' syntax is deprecated in OpenMP v5.2, use '<list> : modifier' instead
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!$omp declare simd linear(val(arg_01))
real, intent(in) :: arg_01(:)
!ERROR: If the `linear-modifier` is REF or UVAL, the list item 'arg_02' must be a dummy argument without the VALUE attribute
!WARNING: The 'modifier(<list>)' syntax is deprecated in OpenMP v5.2, use '<list> : modifier' instead
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!$omp declare simd linear(uval(arg_02))
integer, value, intent(in) :: arg_02
@@ -33,6 +35,7 @@ subroutine linear_clause_02(arg_01, arg_02)
!ERROR: The list item `var` must be a dummy argument
!ERROR: The list item `var` in a LINEAR clause must not be Cray Pointer or a variable with POINTER attribute
!WARNING: The 'modifier(<list>)' syntax is deprecated in OpenMP v5.2, use '<list> : modifier' instead
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!$omp declare simd linear(uval(var))
integer, pointer :: var
end subroutine linear_clause_02
@@ -43,13 +46,16 @@ subroutine linear_clause_03(arg)
!ERROR: List item 'arg' present at multiple LINEAR clauses
!ERROR: 'arg' appears in more than one data-sharing clause on the same OpenMP directive
!WARNING: The 'modifier(<list>)' syntax is deprecated in OpenMP v5.2, use '<list> : modifier' instead
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!$omp declare simd linear(ref(arg)) linear(arg)
integer :: i
common /cc/ i
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!ERROR: The list item `i` must be a dummy argument
!$omp declare simd linear(i)
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!ERROR: 'cc' is a common block name and must not appear in a LINEAR clause
!ERROR: The list item `i` must be a dummy argument
!$omp declare simd linear(/cc/)
@@ -71,6 +77,7 @@ end subroutine linear_clause_04
! Case 5
subroutine linear_clause_05(x)
integer :: x(:)
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!ERROR: The list item `x` specified with the REF 'linear-modifier' must not be a polymorphic variable, an assumed-shape array, or a variable with the `ALLOCATABLE` attribute
!$omp declare simd linear(x : ref)
end subroutine linear_clause_05
@@ -78,6 +85,7 @@ end subroutine linear_clause_05
! Case 6
subroutine linear_clause_06(x)
integer, allocatable :: x(:)
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!ERROR: The list item `x` specified with the REF 'linear-modifier' must not be a polymorphic variable, an assumed-shape array, or a variable with the `ALLOCATABLE` attribute
!$omp declare simd linear(x : ref)
end subroutine linear_clause_06
@@ -85,6 +93,7 @@ end subroutine linear_clause_06
! Case 7
subroutine linear_clause_07(x)
type(*) :: x(:)
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!ERROR: The list item `x` specified with the REF 'linear-modifier' must not be a polymorphic variable, an assumed-shape array, or a variable with the `ALLOCATABLE` attribute
!$omp declare simd linear(x : ref)
end subroutine linear_clause_07
diff --git a/flang/test/Semantics/OpenMP/linear-clause02.f90 b/flang/test/Semantics/OpenMP/linear-clause02.f90
index e6eedbcae7c92..2ac816d1ff3ec 100644
--- a/flang/test/Semantics/OpenMP/linear-clause02.f90
+++ b/flang/test/Semantics/OpenMP/linear-clause02.f90
@@ -3,18 +3,21 @@
subroutine f00(x)
integer :: x
!WARNING: The 'modifier(<list>)' syntax is deprecated in OpenMP v5.2, use '<list> : modifier' instead
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!$omp declare simd linear(uval(x))
end
subroutine f01(x)
integer :: x
!WARNING: The 'modifier(<list>)' syntax is deprecated in OpenMP v5.2, use '<list> : modifier' instead
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!ERROR: An exclusive 'step-simple-modifier' modifier cannot be specified together with a modifier of a different type
!$omp declare simd linear(uval(x) : 2)
end
subroutine f02(x)
integer :: x
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!ERROR: 'step-simple-modifier' modifier cannot occur multiple times
!$omp declare simd linear(x : 2, 2)
end
diff --git a/flang/test/Semantics/OpenMP/linear-clause03.f90 b/flang/test/Semantics/OpenMP/linear-clause03.f90
index dafc2e929801c..0866e38ba1c04 100644
--- a/flang/test/Semantics/OpenMP/linear-clause03.f90
+++ b/flang/test/Semantics/OpenMP/linear-clause03.f90
@@ -6,6 +6,7 @@ module m
subroutine f(x, y)
integer :: x
integer :: y
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!WARNING: 'DECLARE SIMD' directive in an interface body has no effect [-Wopenmp-usage]
!$omp declare simd(f) linear(ref(x) : 1) linear(uval(y))
end
diff --git a/flang/test/Semantics/OpenMP/simd-linear-array.f90 b/flang/test/Semantics/OpenMP/simd-linear-array.f90
index cfebace48ee59..58582b14af67d 100644
--- a/flang/test/Semantics/OpenMP/simd-linear-array.f90
+++ b/flang/test/Semantics/OpenMP/simd-linear-array.f90
@@ -76,6 +76,7 @@ subroutine test_declare_simd_ref_array_valid(arr)
integer, intent(in) :: arr(10)
!WARNING: The 'modifier(<list>)' syntax is deprecated in OpenMP v5.2, use '<list> : modifier' instead
+ !WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
!$omp declare simd linear(ref(arr))
! No error expected - REF modifier allows arrays
end subroutine
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 935aa3232fa2e..1f3d32fd0b993 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -10945,6 +10945,13 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::convertOperation(
.Case([&](omp::GroupprivateOp) {
return convertOmpGroupprivate(*op, builder, moduleTranslation);
})
+ .Case([&](omp::DeclareSimdOp) {
+ // TODO: Implement.
+ // DECLARE_SIMD can be ignored. There is warning emitted in
+ // semantic checks about the current situation, but not having an
+ // implementation should not prevent compilation.
+ return success();
+ })
.Default([&](Operation *inst) {
return inst->emitError()
<< "not yet implemented: " << inst->getName();
``````````
</details>
https://github.com/llvm/llvm-project/pull/232712
More information about the Mlir-commits
mailing list