[clang] [llvm] [Frontend][OpenMP] Remove `reduction` from allowed clauses for `target` (PR #90754)

Krzysztof Parzyszek via cfe-commits cfe-commits at lists.llvm.org
Wed May 22 11:22:58 PDT 2024


https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/90754

>From 94d79223a5c1daab292157576e8e84bb3280f22d Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Wed, 1 May 2024 12:21:51 -0500
Subject: [PATCH] [Frontend][OpenMP] Remove `reduction` from allowed clauses
 for `target`

The "reduction" clause is not allowed on the "target" construct.

The RFC: https://discourse.llvm.org/t/removing-reduction-from-allowed-clauses-for-target-in-omp-td/78881
---
 .../nvptx_target_cuda_mode_messages.cpp       |  18 --
 .../test/OpenMP/target_reduction_codegen.cpp  | 231 -------------
 .../test/OpenMP/target_reduction_messages.cpp | 304 ------------------
 clang/test/OpenMP/target_vla_messages.cpp     |   6 -
 llvm/include/llvm/Frontend/OpenMP/OMP.td      |   1 -
 5 files changed, 560 deletions(-)
 delete mode 100644 clang/test/OpenMP/target_reduction_codegen.cpp
 delete mode 100644 clang/test/OpenMP/target_reduction_messages.cpp

diff --git a/clang/test/OpenMP/nvptx_target_cuda_mode_messages.cpp b/clang/test/OpenMP/nvptx_target_cuda_mode_messages.cpp
index b70136bcdc2d9..266483f555092 100644
--- a/clang/test/OpenMP/nvptx_target_cuda_mode_messages.cpp
+++ b/clang/test/OpenMP/nvptx_target_cuda_mode_messages.cpp
@@ -46,23 +46,6 @@ int foo(int n, double *ptr) {
   return a;
 }
 
-template <typename tx>
-tx ftemplate(int n) {
-  tx a = 0;
-  tx b[10];
-
-#pragma omp target reduction(+ \
-                             : a, b) // expected-note {{defined as threadprivate or thread local}}
-  {
-    int e;                        // expected-note {{defined as threadprivate or thread local}}
-#pragma omp parallel shared(a, e) // expected-error 2 {{threadprivate or thread local variable cannot be shared}}
-    a += 1;
-    b[2] += 1;
-  }
-
-  return a;
-}
-
 static int fstatic(int n) {
   int a = 0;
   char aaa = 0;
@@ -101,7 +84,6 @@ int bar(int n, double *ptr) {
   S1 S;
   a += S.r1(n);
   a += fstatic(n);
-  a += ftemplate<int>(n); // expected-note {{in instantiation of function template specialization 'ftemplate<int>' requested here}}
 
   return a;
 }
diff --git a/clang/test/OpenMP/target_reduction_codegen.cpp b/clang/test/OpenMP/target_reduction_codegen.cpp
deleted file mode 100644
index 9f113be62beb5..0000000000000
--- a/clang/test/OpenMP/target_reduction_codegen.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
-// Only test codegen on target side, as private clause does not require any action on the host side
-// Test target codegen - host bc file has to be created first.
-// RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
-// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
-// RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
-// RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-32
-// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-32
-
-// RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
-// RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
-
-// expected-no-diagnostics
-#ifndef HEADER
-#define HEADER
-
-template<typename tx, typename ty>
-struct TT{
-  tx X;
-  ty Y;
-  TT<tx, ty> operator*(const TT<tx, ty> &) { return *this; }
-};
-
-// TCHECK: [[S1:%.+]] = type { double }
-
-int foo(int n) {
-  int a = 0;
-  short aa = 0;
-  float b[10];
-  float bn[n];
-  double c[5][10];
-  double cn[5][n];
-  TT<long long, char> d;
-
-  #pragma omp target reduction(*:a)
-  {
-  }
-
-  // TCHECK: define weak_odr protected void @__omp_offloading_{{.+}}(ptr {{[^,]+}}, ptr{{.+}} %{{.+}})
-  // TCHECK: [[DYN_PTR:%.+]] = alloca ptr,
-  // TCHECK: [[A:%.+]] = alloca ptr,
-  // TCHECK: store {{.+}}, {{.+}} [[A]],
-  // TCHECK: load ptr, ptr [[A]],
-  // TCHECK: ret void
-
-#pragma omp target reduction(+:a)
-  {
-    a = 1;
-  }
-
-  // TCHECK:  define weak_odr protected void @__omp_offloading_{{.+}}(ptr {{[^,]+}}, ptr{{.+}} %{{.+}})
-  // TCHECK: [[DYN_PTR:%.+]] = alloca ptr,
-  // TCHECK: [[A:%.+]] = alloca ptr,
-  // TCHECK: store {{.+}}, {{.+}} [[A]],
-  // TCHECK: [[REF:%.+]] = load ptr, ptr [[A]],
-  // TCHECK: store i{{[0-9]+}} 1, ptr [[REF]],
-  // TCHECK: ret void
-
-  #pragma omp target reduction(-:a, aa)
-  {
-    a = 1;
-    aa = 1;
-  }
-
-  // TCHECK:  define weak_odr protected void @__omp_offloading_{{.+}}(ptr {{[^,]+}}, ptr{{.+}} [[A:%.+]], ptr{{.+}} [[AA:%.+]])
-  // TCHECK: [[DYN_PTR:%.+]] = alloca ptr,
-  // TCHECK:  [[A:%.+]] = alloca ptr,
-  // TCHECK:  [[AA:%.+]] = alloca ptr,
-  // TCHECK: store {{.+}}, {{.+}} [[A]],
-  // TCHECK: store {{.+}}, {{.+}} [[AA]],
-  // TCHECK: [[A_REF:%.+]] = load ptr, ptr [[A]],
-  // TCHECK: [[AA_REF:%.+]] = load ptr, ptr [[AA]],
-  // TCHECK:  store i{{[0-9]+}} 1, ptr [[A_REF]],
-  // TCHECK:  store i{{[0-9]+}} 1, ptr [[AA_REF]],
-  // TCHECK:  ret void
-
-  return a;
-}
-
-
-template<typename tx>
-tx ftemplate(int n) {
-  tx a = 0;
-  short aa = 0;
-  tx b[10];
-
-#pragma omp target reduction(+:a,aa,b)
-  {
-    a = 1;
-    aa = 1;
-    b[2] = 1;
-  }
-
-  return a;
-}
-
-static
-int fstatic(int n) {
-  int a = 0;
-  short aa = 0;
-  char aaa = 0;
-  int b[10];
-
-#pragma omp target reduction(-:a,aa,aaa,b)
-  {
-    a = 1;
-    aa = 1;
-    aaa = 1;
-    b[2] = 1;
-  }
-
-  return a;
-}
-
-// TCHECK: define weak_odr protected void @__omp_offloading_{{.+}}(ptr {{[^,]+}}, ptr{{.+}}, ptr{{.+}}, ptr{{.+}}, ptr{{.+}})
-// TCHECK: [[DYN_PTR:%.+]] = alloca ptr,
-// TCHECK:  [[A:%.+]] = alloca ptr,
-// TCHECK:  [[A2:%.+]] = alloca ptr,
-// TCHECK:  [[A3:%.+]] = alloca ptr,
-// TCHECK:  [[B:%.+]] = alloca ptr,
-// TCHECK: store {{.+}}, {{.+}} [[A]],
-// TCHECK: store {{.+}}, {{.+}} [[A2]],
-// TCHECK: store {{.+}}, {{.+}} [[A3]],
-// TCHECK: store {{.+}}, {{.+}} [[B]],
-// TCHECK: [[A_REF:%.+]] = load ptr, ptr [[A]],
-// TCHECK: [[AA_REF:%.+]] = load ptr, ptr [[AA]],
-// TCHECK: [[A3_REF:%.+]] = load ptr, ptr [[A3]],
-// TCHECK: [[B_REF:%.+]] = load ptr, ptr [[B]],
-// TCHECK:  store i{{[0-9]+}} 1, ptr [[A_REF]],
-// TCHECK:  store i{{[0-9]+}} 1, ptr [[AA_REF]],
-// TCHECK:  store i{{[0-9]+}} 1, ptr [[A3_REF]],
-// TCHECK:  [[B_GEP:%.+]] = getelementptr inbounds [10 x i{{[0-9]+}}], ptr [[B_REF]], i{{[0-9]+}} 0, i{{[0-9]+}} 2
-// TCHECK:  store i{{[0-9]+}} 1, ptr [[B_GEP]],
-// TCHECK:  ret void
-
-struct S1 {
-  double a;
-
-  int r1(int n){
-    int b = n+1;
-    short int c[2][n];
-
-#pragma omp target reduction(max:b,c)
-    {
-      this->a = (double)b + 1.5;
-      c[1][1] = ++a;
-    }
-
-    return c[1][1] + (int)b;
-  }
-
-  // TCHECK: define weak_odr protected void @__omp_offloading_{{.+}}(ptr {{[^,]+}}, ptr noundef [[TH:%.+]], ptr{{.+}}, i{{[0-9]+}} noundef [[VLA:%.+]], i{{[0-9]+}} noundef [[VLA1:%.+]], ptr{{.+}})
-  // TCHECK: [[DYN_PTR:%.+]] = alloca ptr,
-  // TCHECK: [[TH_ADDR:%.+]] = alloca ptr,
-  // TCHECK: [[B_ADDR:%.+]] = alloca ptr,
-  // TCHECK: [[VLA_ADDR:%.+]] = alloca i{{[0-9]+}},
-  // TCHECK: [[VLA_ADDR2:%.+]] = alloca i{{[0-9]+}},
-  // TCHECK: [[C_ADDR:%.+]] = alloca ptr,
-  // TCHECK: store ptr [[TH]], ptr [[TH_ADDR]],
-  // TCHECK: store ptr {{.+}}, ptr [[B_ADDR]],
-  // TCHECK: store i{{[0-9]+}} [[VLA]], ptr [[VLA_ADDR]],
-  // TCHECK: store i{{[0-9]+}} [[VLA1]], ptr [[VLA_ADDR2]],
-  // TCHECK: store ptr {{.+}}, ptr [[C_ADDR]],
-  // TCHECK: [[TH_ADDR_REF:%.+]] = load ptr, ptr [[TH_ADDR]],
-  // TCHECK: [[B_REF:%.+]] = load ptr, ptr [[B_ADDR]],
-  // TCHECK: [[VLA_ADDR_REF:%.+]] = load i{{[0-9]+}}, ptr [[VLA_ADDR]],
-  // TCHECK: [[VLA_ADDR_REF2:%.+]] = load i{{[0-9]+}}, ptr [[VLA_ADDR2]],
-  // TCHECK: [[C_REF:%.+]] = load ptr, ptr [[C_ADDR]],
-
-  // this->a = (double)b + 1.5;
-  // TCHECK: [[B_VAL:%.+]] = load i{{[0-9]+}}, ptr [[B_REF]],
-  // TCHECK: [[B_CONV:%.+]] = sitofp i{{[0-9]+}} [[B_VAL]] to double
-  // TCHECK: [[NEW_A_VAL:%.+]] = fadd double [[B_CONV]], 1.5{{.+}}+00
-  // TCHECK: [[A_FIELD:%.+]] = getelementptr inbounds [[S1]], ptr [[TH_ADDR_REF]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
-  // TCHECK: store double [[NEW_A_VAL]], ptr [[A_FIELD]],
-
-  // c[1][1] = ++a;
-  // TCHECK: [[A_FIELD4:%.+]] = getelementptr inbounds [[S1]], ptr [[TH_ADDR_REF]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
-  // TCHECK: [[A_FIELD4_VAL:%.+]] = load double, ptr [[A_FIELD4]],
-  // TCHECK: [[A_FIELD_INC:%.+]] = fadd double [[A_FIELD4_VAL]], 1.0{{.+}}+00
-  // TCHECK: store double [[A_FIELD_INC]], ptr [[A_FIELD4]],
-  // TCHECK: [[A_FIELD_INC_CONV:%.+]] = fptosi double [[A_FIELD_INC]] to i{{[0-9]+}}
-  // TCHECK: [[C_IND:%.+]] = mul{{.+}} i{{[0-9]+}} 1, [[VLA_ADDR_REF2]]
-  // TCHECK: [[C_1_REF:%.+]] = getelementptr inbounds i{{[0-9]+}}, ptr [[C_REF]], i{{[0-9]+}} [[C_IND]]
-  // TCHECK: [[C_1_1_REF:%.+]] = getelementptr inbounds i{{[0-9]+}}, ptr [[C_1_REF]], i{{[0-9]+}} 1
-  // TCHECK: store i{{[0-9]+}} [[A_FIELD_INC_CONV]], ptr [[C_1_1_REF]],
-
-  // finish
-  // TCHECK: ret void
-};
-
-
-int bar(int n){
-  int a = 0;
-  a += foo(n);
-  S1 S;
-  a += S.r1(n);
-  a += fstatic(n);
-  a += ftemplate<int>(n);
-
-  return a;
-}
-
-// template
-// TCHECK: define weak_odr protected void @__omp_offloading_{{.+}}(ptr {{[^,]+}}, ptr{{.+}}, ptr{{.+}}, ptr{{.+}})
-// TCHECK: [[DYN_PTR:%.+]] = alloca ptr,
-// TCHECK: [[A:%.+]] = alloca ptr,
-// TCHECK: [[A2:%.+]] = alloca ptr,
-// TCHECK: [[B:%.+]] = alloca ptr,
-// TCHECK: store {{.+}}, {{.+}} [[A]],
-// TCHECK: store {{.+}}, {{.+}} [[A2]],
-// TCHECK: store {{.+}}, {{.+}} [[B]],
-// TCHECK: [[A_REF:%.+]] = load ptr, ptr [[A]],
-// TCHECK: [[AA_REF:%.+]] = load ptr, ptr [[AA]],
-// TCHECK: [[B_REF:%.+]] = load ptr, ptr [[B]],
-// TCHECK: store i{{[0-9]+}} 1, ptr [[A_REF]],
-// TCHECK: store i{{[0-9]+}} 1, ptr [[AA_REF]],
-// TCHECK: [[B_GEP:%.+]] = getelementptr inbounds [10 x i{{[0-9]+}}], ptr [[B_REF]], i{{[0-9]+}} 0, i{{[0-9]+}} 2
-// TCHECK: store i{{[0-9]+}} 1, ptr [[B_GEP]],
-// TCHECK: ret void
-
-#endif
diff --git a/clang/test/OpenMP/target_reduction_messages.cpp b/clang/test/OpenMP/target_reduction_messages.cpp
deleted file mode 100644
index 915931c930e1a..0000000000000
--- a/clang/test/OpenMP/target_reduction_messages.cpp
+++ /dev/null
@@ -1,304 +0,0 @@
-// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -std=c++98 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -std=c++11 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -std=c++98 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -std=c++11 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -std=c++98 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -std=c++11 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp -fopenmp-version=60 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp -fopenmp-version=60 -std=c++98 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp -fopenmp-version=60 -std=c++11 -ferror-limit 150 -o - %s -Wuninitialized
-
-// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -std=c++98 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -std=c++11 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -std=c++98 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -std=c++11 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 -std=c++98 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 -std=c++11 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp-simd -fopenmp-version=60 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp-simd -fopenmp-version=60 -std=c++98 -ferror-limit 150 -o - %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp-simd -fopenmp-version=60 -std=c++11 -ferror-limit 150 -o - %s -Wuninitialized
-
-typedef void **omp_allocator_handle_t;
-extern const omp_allocator_handle_t omp_null_allocator;
-extern const omp_allocator_handle_t omp_default_mem_alloc;
-extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
-extern const omp_allocator_handle_t omp_const_mem_alloc;
-extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
-extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
-extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
-extern const omp_allocator_handle_t omp_pteam_mem_alloc;
-extern const omp_allocator_handle_t omp_thread_mem_alloc;
-
-void xxx(int argc) {
-  int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
-#pragma omp target reduction(+:fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
-  for (int i = 0; i < 10; ++i)
-    ;
-}
-
-void foo() {
-}
-
-bool foobool(int argc) {
-  return argc;
-}
-
-void foobar(int &ref) {
-#pragma omp target reduction(+:ref)
-  foo();
-}
-
-struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
-extern S1 a;
-class S2 {
-  mutable int a;
-  S2 &operator+(const S2 &arg) { return (*this); } // expected-note 3 {{implicitly declared private here}}
-
-public:
-  S2() : a(0) {}
-  S2(S2 &s2) : a(s2.a) {}
-  static float S2s; // expected-note 2 {{static data member is predetermined as shared}}
-  static const float S2sc; // expected-note 2 {{'S2sc' declared here}}
-};
-const float S2::S2sc = 0;
-S2 b;                     // expected-note 3 {{'b' defined here}}
-const S2 ba[5];           // expected-note 2 {{'ba' defined here}}
-class S3 {
-  int a;
-
-public:
-  int b;
-  S3() : a(0) {}
-  S3(const S3 &s3) : a(s3.a) {}
-  S3 operator+(const S3 &arg1) { return arg1; }
-};
-int operator+(const S3 &arg1, const S3 &arg2) { return 5; }
-S3 c;               // expected-note 3 {{'c' defined here}}
-const S3 ca[5];     // expected-note 2 {{'ca' defined here}}
-extern const int f; // expected-note 4 {{'f' declared here}}
-class S4 {
-  int a;
-  S4(); // expected-note {{implicitly declared private here}}
-  S4(const S4 &s4);
-  S4 &operator+(const S4 &arg) { return (*this); }
-
-public:
-  S4(int v) : a(v) {}
-};
-S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; }
-class S5 {
-  int a;
-  S5() : a(0) {} // expected-note {{implicitly declared private here}}
-  S5(const S5 &s5) : a(s5.a) {}
-  S5 &operator+(const S5 &arg);
-
-public:
-  S5(int v) : a(v) {}
-};
-class S6 { // expected-note 3 {{candidate function (the implicit copy assignment operator) not viable: no known conversion from 'int' to 'const S6' for 1st argument}}
-#if __cplusplus >= 201103L // C++11 or later
-// expected-note at -2 3 {{candidate function (the implicit move assignment operator) not viable}}
-#endif
-  int a;
-
-public:
-  S6() : a(6) {}
-  operator int() { return 6; }
-} o;
-
-S3 h, k;
-#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
-
-template <class T>       // expected-note {{declared here}}
-T tmain(T argc) {
-  const T d = T();       // expected-note 4 {{'d' defined here}}
-  const T da[5] = {T()}; // expected-note 2 {{'da' defined here}}
-  T qa[5] = {T()};
-  T i, z;
-  T &j = i;                    // expected-note 4 {{'j' defined here}}
-  S3 &p = k;                   // expected-note 2 {{'p' defined here}}
-  const T &r = da[(int)i];     // expected-note 2 {{'r' defined here}}
-  T &q = qa[(int)i];           // expected-note 2 {{'q' defined here}}
-  T fl;
-#pragma omp target reduction // expected-error {{expected '(' after 'reduction'}}
-  foo();
-#pragma omp target reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
-  foo();
-#pragma omp target reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-  foo();
-#pragma omp target reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-  foo();
-#pragma omp target reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
-  foo();
-#pragma omp target reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
-  foo();
-#pragma omp target reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
-  foo();
-#pragma omp target reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
-  foo();
-#pragma omp target reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
-  foo();
-#pragma omp target reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}}
-  foo();
-#pragma omp target reduction(foo : argc) //omp45-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'float'}} omp45-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'int'}} omp50-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'float'}} omp50-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'int'}} omp52-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'float'}} omp52-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'int'}} omp60-error {{incorrect reduction identifier, expected one of '+', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'float'}} omp60-error {{incorrect reduction identifier, expected one of '+', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'int'}}
-  foo();
-#pragma omp target reduction(&& : argc, z)
-  foo();
-#pragma omp target reduction(^ : T) // expected-error {{'T' does not refer to a value}}
-  foo();
-#pragma omp target reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 3 {{const-qualified variable cannot be reduction}} expected-error 2 {{'operator+' is a private member of 'S2'}}
-  foo();
-#pragma omp target reduction(min : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 4 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 3 {{const-qualified variable cannot be reduction}}
-  foo();
-#pragma omp target reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
-  foo();
-#pragma omp target reduction(+ : ba) // expected-error {{const-qualified variable cannot be reduction}}
-  foo();
-#pragma omp target reduction(* : ca) // expected-error {{const-qualified variable cannot be reduction}}
-  foo();
-#pragma omp target reduction(- : da) // expected-error 2 {{const-qualified variable cannot be reduction}} omp52-warning 3 {{minus(-) operator for reductions is deprecated; use + or user defined reduction instead}}
-  foo();
-#pragma omp target reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
-  foo();
-#pragma omp target reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
-  foo();
-#pragma omp target reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
-  foo();
-#pragma omp target reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
-  foo();
-#pragma omp target reduction(+ : o) // expected-error 2 {{no viable overloaded '='}}
-  foo();
-#pragma omp parallel private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
-  foo();
-#pragma omp parallel private(k)
-#pragma omp target reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
-  foo();
-#pragma omp target reduction(+ : p), reduction(+ : p) // expected-error 2 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 2 {{previously referenced here}}
-  foo();
-#pragma omp target reduction(+ : r) // expected-error 2 {{const-qualified variable cannot be reduction}}
-  foo();
-#pragma omp parallel shared(i)
-#pragma omp target reduction(min : i)
-#pragma omp parallel reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
-  foo();
-#pragma omp parallel
-#pragma omp for private(fl)
-  for (int i = 0; i < 10; ++i)
-#pragma omp target reduction(+ : fl) allocate(omp_thread_mem_alloc: fl) // expected-warning 2 {{allocator with the 'thread' trait access has unspecified behavior on 'target' directive}} omp50-error 2 {{allocator must be specified in the 'uses_allocators' clause}} omp52-error 2 {{allocator must be specified in the 'uses_allocators' clause}} omp60-error 2 {{allocator must be specified in the 'uses_allocators' clause}}
-    foo();
-#pragma omp parallel
-#pragma omp for reduction(- : fl) // omp52-warning 3 {{minus(-) operator for reductions is deprecated; use + or user defined reduction instead}} omp60-error{{incorrect reduction identifier, expected one of '+', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'int'}} omp60-error{{incorrect reduction identifier, expected one of '+', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'float'}}
-  for (int i = 0; i < 10; ++i)
-#pragma omp target reduction(+ : fl)
-    foo();
-
-  return T();
-}
-
-namespace A {
-double x;
-#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
-}
-namespace B {
-using A::x;
-}
-
-int main(int argc, char **argv) {
-  const int d = 5;       // expected-note 2 {{'d' defined here}}
-  const int da[5] = {0}; // expected-note {{'da' defined here}}
-  int qa[5] = {0};
-  S4 e(4);
-  S5 g(5);
-  int i, z;
-  int &j = i;                  // expected-note 2 {{'j' defined here}}
-  S3 &p = k;                   // expected-note 2 {{'p' defined here}}
-  const int &r = da[i];        // expected-note {{'r' defined here}}
-  int &q = qa[i];              // expected-note {{'q' defined here}}
-  float fl;
-#pragma omp target reduction // expected-error {{expected '(' after 'reduction'}}
-  foo();
-#pragma omp target reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
-  foo();
-#pragma omp target reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-  foo();
-#pragma omp target reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-  foo();
-#pragma omp target reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
-  foo();
-#pragma omp target reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
-  foo();
-#pragma omp target reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
-  foo();
-#pragma omp target reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} omp45-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}} omp50-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}} omp52-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}  omp60-error {{incorrect reduction identifier, expected one of '+', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
-  foo();
-#pragma omp target reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-  foo();
-#pragma omp target reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}
-  foo();
-#pragma omp target reduction(~ : argc) // expected-error {{expected unqualified-id}}
-  foo();
-#pragma omp target reduction(&& : argc) allocate , allocate(, allocate(omp_default , allocate(omp_default_mem_alloc, allocate(omp_default_mem_alloc:, allocate(omp_default_mem_alloc: argc, allocate(omp_default_mem_alloc: argv), allocate(argv) // expected-error {{expected '(' after 'allocate'}} expected-error 2 {{expected expression}} expected-error 2 {{expected ')'}} expected-error {{use of undeclared identifier 'omp_default'}} expected-note 2 {{to match this '('}}
-  foo();
-#pragma omp target reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
-  foo();
-#pragma omp target reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{const-qualified variable cannot be reduction}} expected-error {{'operator+' is a private member of 'S2'}}
-  foo();
-#pragma omp target reduction(min : z, a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 2 {{const-qualified variable cannot be reduction}}
-  foo();
-#pragma omp target reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
-  foo();
-#pragma omp target reduction(+ : ba) // expected-error {{const-qualified variable cannot be reduction}}
-  foo();
-#pragma omp target reduction(* : ca) // expected-error {{const-qualified variable cannot be reduction}}
-  foo();
-#pragma omp target reduction(- : da) // expected-error {{const-qualified variable cannot be reduction}} omp52-warning {{minus(-) operator for reductions is deprecated; use + or user defined reduction instead}}
-  foo();
-#pragma omp target reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
-  foo();
-#pragma omp target reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
-  foo();
-#pragma omp target reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
-  foo();
-#pragma omp target reduction(& : e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} expected-error {{invalid operands to binary expression ('S5' and 'S5')}}
-  foo();
-#pragma omp target reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}
-  foo();
-#pragma omp target reduction(+ : o) // expected-error {{no viable overloaded '='}}
-  foo();
-#pragma omp parallel private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
-  foo();
-#pragma omp parallel private(k)
-#pragma omp target reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
-  foo();
-#pragma omp target reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}
-  foo();
-#pragma omp target reduction(+ : r) // expected-error {{const-qualified variable cannot be reduction}}
-  foo();
-#pragma omp parallel shared(i)
-#pragma omp target reduction(min : i)
-#pragma omp parallel reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
-  foo();
-#pragma omp parallel
-#pragma omp for private(fl)
-  for (int i = 0; i < 10; ++i)
-#pragma omp target reduction(+ : fl)
-    foo();
-#pragma omp parallel
-#pragma omp for reduction(- : fl) // omp52-warning {{minus(-) operator for reductions is deprecated; use + or user defined reduction instead}} omp60-error{{incorrect reduction identifier, expected one of '+', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'float'}}
-  for (int i = 0; i < 10; ++i)
-#pragma omp target reduction(+ : fl)
-    foo();
-  static int m;
-#pragma omp target reduction(+ : m) // OK
-  m++;
-#pragma omp target reduction(task, + : m) // omp45-error 2 {{expected expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}} omp50-error {{'reduction' clause with 'task' modifier allowed only on non-simd parallel or worksharing constructs}} omp52-error {{'reduction' clause with 'task' modifier allowed only on non-simd parallel or worksharing constructs}} omp60-error {{'reduction' clause with 'task' modifier allowed only on non-simd parallel or worksharing constructs}}
-  m++;
-
-  return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain<int>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<float>' requested here}}
-}
diff --git a/clang/test/OpenMP/target_vla_messages.cpp b/clang/test/OpenMP/target_vla_messages.cpp
index 5563fc3ee005e..3cf6466aee6c9 100644
--- a/clang/test/OpenMP/target_vla_messages.cpp
+++ b/clang/test/OpenMP/target_vla_messages.cpp
@@ -206,10 +206,4 @@ void for_reduction(int arg) {
 #pragma omp parallel
 #pragma omp for reduction(+: vla[0:arg])
   for (int i = 0; i < arg; i++) ;
-#ifdef NO_VLA
-  // expected-error at +3 {{cannot generate code for reduction on array section, which requires a variable length array}}
-  // expected-note at +2 {{variable length arrays are not supported for the current target}}
-#endif
-#pragma omp target reduction(+ : vla[0:arg])
-  for (int i = 0; i < arg; i++) ;
 }
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td
index e91169e8da1aa..609df6a4c54aa 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -682,7 +682,6 @@ def OMP_Target : Directive<"target"> {
     VersionedClause<OMPC_FirstPrivate>,
     VersionedClause<OMPC_IsDevicePtr>,
     VersionedClause<OMPC_HasDeviceAddr, 51>,
-    VersionedClause<OMPC_Reduction>,
     VersionedClause<OMPC_InReduction, 50>,
     VersionedClause<OMPC_Allocate>,
     VersionedClause<OMPC_UsesAllocators, 50>,



More information about the cfe-commits mailing list