r283223 - [OpenMP] fix segfault when a variable referenced in reduction clause is a reference parameter\nDifferential Revision: http://reviews.llvm.org/D24524

David Sheinkman via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 4 07:41:37 PDT 2016


Author: davidsh
Date: Tue Oct  4 09:41:36 2016
New Revision: 283223

URL: http://llvm.org/viewvc/llvm-project?rev=283223&view=rev
Log:
[OpenMP] fix segfault when a variable referenced in reduction clause is a reference parameter\nDifferential Revision: http://reviews.llvm.org/D24524

Modified:
    cfe/trunk/lib/Sema/SemaOpenMP.cpp
    cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_messages.cpp
    cfe/trunk/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp
    cfe/trunk/test/OpenMP/distribute_simd_reduction_messages.cpp
    cfe/trunk/test/OpenMP/for_reduction_messages.cpp
    cfe/trunk/test/OpenMP/for_simd_reduction_messages.cpp
    cfe/trunk/test/OpenMP/parallel_for_reduction_messages.cpp
    cfe/trunk/test/OpenMP/parallel_for_simd_reduction_messages.cpp
    cfe/trunk/test/OpenMP/parallel_reduction_messages.cpp
    cfe/trunk/test/OpenMP/parallel_sections_reduction_messages.cpp
    cfe/trunk/test/OpenMP/sections_reduction_messages.cpp
    cfe/trunk/test/OpenMP/simd_reduction_messages.cpp
    cfe/trunk/test/OpenMP/target_parallel_for_reduction_messages.cpp
    cfe/trunk/test/OpenMP/target_parallel_for_simd_reduction_messages.cpp
    cfe/trunk/test/OpenMP/target_parallel_reduction_messages.cpp
    cfe/trunk/test/OpenMP/target_simd_reduction_messages.cpp
    cfe/trunk/test/OpenMP/teams_distribute_reduction_messages.cpp
    cfe/trunk/test/OpenMP/teams_reduction_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Oct  4 09:41:36 2016
@@ -9401,7 +9401,7 @@ OMPClause *Sema::ActOnOpenMPReductionCla
     //  for all threads of the team.
     if (!ASE && !OASE && VD) {
       VarDecl *VDDef = VD->getDefinition();
-      if (VD->getType()->isReferenceType() && VDDef) {
+      if (VD->getType()->isReferenceType() && VDDef && VDDef->hasInit()) {
         DSARefChecker Check(DSAStack);
         if (Check.Visit(VDDef->getInit())) {
           Diag(ELoc, diag::err_omp_reduction_ref_type_arg) << ERange;

Modified: cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,14 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute parallel for reduction(+:ref)
+  for (int i = 0; i < 10; ++i)
+    foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,14 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute parallel for simd reduction(+:ref)
+  for (int i = 0; i < 10; ++i)
+    foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/distribute_simd_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_simd_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/distribute_simd_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/distribute_simd_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,14 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd reduction(+:ref)
+  for (int i = 0; i < 10; ++i)
+    foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/for_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/for_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,13 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp parallel
+#pragma omp for reduction(+:ref)
+  for (int i = 0; i < 10; ++i)
+    foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/for_simd_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_simd_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/for_simd_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/for_simd_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,13 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp parallel
+#pragma omp for simd reduction(+:ref)
+  for (int i = 0; i < 10; ++i)
+    foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/parallel_for_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/parallel_for_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,12 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp parallel for reduction(+:ref)
+  for (int i = 0; i < 10; ++i)
+    foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/parallel_for_simd_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_simd_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/parallel_for_simd_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_simd_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,12 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp parallel for simd reduction(+:ref)
+  for (int i = 0; i < 10; ++i)
+    foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/parallel_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/parallel_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,11 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp parallel reduction(+:ref)
+  foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/parallel_sections_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_sections_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/parallel_sections_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_sections_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,13 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp parallel sections reduction(+:ref)
+  {
+    foo();
+  }
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/sections_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/sections_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/sections_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/sections_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,14 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp parallel   
+#pragma omp sections reduction(+:ref)
+  {
+    foo();
+  }
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/simd_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/simd_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/simd_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/simd_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,12 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp simd reduction(+:ref)
+  for (int i = 0; i < 10; ++i)
+    foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/target_parallel_for_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_for_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/target_parallel_for_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/target_parallel_for_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,12 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp target parallel for reduction(+:ref)
+  for (int i = 0; i < 10; ++i)
+    foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/target_parallel_for_simd_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_for_simd_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/target_parallel_for_simd_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/target_parallel_for_simd_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,12 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp target parallel for simd reduction(+:ref)
+  for (int i = 0; i < 10; ++i)
+    foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/target_parallel_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/target_parallel_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/target_parallel_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,11 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp target parallel reduction(+:ref)
+  foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/target_simd_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_simd_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/target_simd_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/target_simd_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,12 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp target simd reduction(+:ref)
+  for (int i = 0; i < 10; ++i)
+    foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/teams_distribute_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/teams_distribute_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/teams_distribute_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,12 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp target
+#pragma omp teams distribute reduction(+:ref)
+  for (int j=0; j<100; j++) foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/teams_reduction_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/teams_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/teams_reduction_messages.cpp Tue Oct  4 09:41:36 2016
@@ -9,6 +9,12 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp target
+#pragma omp teams reduction(+:ref)
+  foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {




More information about the cfe-commits mailing list