[llvm-branch-commits] [cfe-branch] r287816 - Merging r275926:
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Nov 23 13:29:33 PST 2016
Author: tstellar
Date: Wed Nov 23 15:29:33 2016
New Revision: 287816
URL: http://llvm.org/viewvc/llvm-project?rev=287816&view=rev
Log:
Merging r275926:
------------------------------------------------------------------------
r275926 | kkwli0 | 2016-07-18 15:49:16 -0700 (Mon, 18 Jul 2016) | 25 lines
[OpenMP] Fix incorrect diagnostics in map clause
Having the following code pattern will result in incorrect diagnostic
int main() {
int arr[10];
#pragma omp target data map(arr[:])
#pragma omp target map(arr)
{}
}
t.cpp:4:24: error: original storage of expression in data environment is shared
but data environment do not fully contain mapped expression storage
#pragma omp target map(arr)
^~~
t.cpp:3:29: note: used here
#pragma omp target data map(arr[:])
^~~~~~
1 error generated.
Patch by David S.
Differential Revision: https://reviews.llvm.org/D22075
------------------------------------------------------------------------
Modified:
cfe/branches/release_39/lib/Sema/SemaOpenMP.cpp
cfe/branches/release_39/test/OpenMP/target_map_messages.cpp
cfe/branches/release_39/test/OpenMP/target_parallel_for_map_messages.cpp
cfe/branches/release_39/test/OpenMP/target_parallel_for_simd_map_messages.cpp
cfe/branches/release_39/test/OpenMP/target_parallel_map_messages.cpp
Modified: cfe/branches/release_39/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/Sema/SemaOpenMP.cpp?rev=287816&r1=287815&r2=287816&view=diff
==============================================================================
--- cfe/branches/release_39/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/branches/release_39/lib/Sema/SemaOpenMP.cpp Wed Nov 23 15:29:33 2016
@@ -10680,6 +10680,25 @@ static bool CheckMapConflicts(
if (CI->getAssociatedDeclaration() != SI->getAssociatedDeclaration())
break;
}
+ // Check if the extra components of the expressions in the enclosing
+ // data environment are redundant for the current base declaration.
+ // If they are, the maps completely overlap, which is legal.
+ for (; SI != SE; ++SI) {
+ QualType Type;
+ if (auto *ASE =
+ dyn_cast<ArraySubscriptExpr>(SI->getAssociatedExpression())) {
+ Type = ASE->getBase()->IgnoreParenImpCasts()->getType();
+ } else if (auto *OASE =
+ dyn_cast<OMPArraySectionExpr>(SI->getAssociatedExpression())) {
+ auto *E = OASE->getBase()->IgnoreParenImpCasts();
+ Type =
+ OMPArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
+ }
+ if (Type.isNull() || Type->isAnyPointerType() ||
+ CheckArrayExpressionDoesNotReferToWholeSize(
+ SemaRef, SI->getAssociatedExpression(), Type))
+ break;
+ }
// OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.4]
// List items of map clauses in the same construct must not share
Modified: cfe/branches/release_39/test/OpenMP/target_map_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/OpenMP/target_map_messages.cpp?rev=287816&r1=287815&r2=287816&view=diff
==============================================================================
--- cfe/branches/release_39/test/OpenMP/target_map_messages.cpp (original)
+++ cfe/branches/release_39/test/OpenMP/target_map_messages.cpp Wed Nov 23 15:29:33 2016
@@ -284,6 +284,11 @@ void SAclient(int arg) {
{}
}
}
+ #pragma omp target data map(marr[:][:][:])
+ {
+ #pragma omp target data map(marr)
+ {}
+ }
#pragma omp target data map(to: t)
{
@@ -419,10 +424,10 @@ T tmain(T argc) {
#pragma omp target data map(j)
#pragma omp target map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 4 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
#pragma omp target data map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
#pragma omp target data map(j)
-#pragma omp target map(l) // expected-error 2 {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+#pragma omp target map(l)
foo();
#pragma omp target data map(always, tofrom: x)
@@ -488,10 +493,10 @@ int main(int argc, char **argv) {
#pragma omp target data map(j)
#pragma omp target map(l) map(l[:5]) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}}
foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}}
#pragma omp target data map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
#pragma omp target data map(j)
-#pragma omp target map(l) // expected-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+#pragma omp target map(l)
foo();
#pragma omp target data map(always, tofrom: x)
Modified: cfe/branches/release_39/test/OpenMP/target_parallel_for_map_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/OpenMP/target_parallel_for_map_messages.cpp?rev=287816&r1=287815&r2=287816&view=diff
==============================================================================
--- cfe/branches/release_39/test/OpenMP/target_parallel_for_map_messages.cpp (original)
+++ cfe/branches/release_39/test/OpenMP/target_parallel_for_map_messages.cpp Wed Nov 23 15:29:33 2016
@@ -143,13 +143,13 @@ T tmain(T argc) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target parallel for map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
for (i = 0; i < argc; ++i) foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 4 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
{
#pragma omp target parallel for map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target parallel for map(j)
for (i = 0; i < argc; ++i) foo();
-#pragma omp target parallel for map(l) // expected-error 2 {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+#pragma omp target parallel for map(l)
for (i = 0; i < argc; ++i) foo();
}
@@ -247,13 +247,13 @@ int main(int argc, char **argv) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target parallel for map(l) map(l[:5]) // expected-error 1 {{variable already marked as mapped in current construct}} expected-note 1 {{used here}}
for (i = 0; i < argc; ++i) foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}}
{
#pragma omp target parallel for map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target parallel for map(j)
for (i = 0; i < argc; ++i) foo();
-#pragma omp target parallel for map(l) // expected-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+#pragma omp target parallel for map(l)
for (i = 0; i < argc; ++i) foo();
}
Modified: cfe/branches/release_39/test/OpenMP/target_parallel_for_simd_map_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/OpenMP/target_parallel_for_simd_map_messages.cpp?rev=287816&r1=287815&r2=287816&view=diff
==============================================================================
--- cfe/branches/release_39/test/OpenMP/target_parallel_for_simd_map_messages.cpp (original)
+++ cfe/branches/release_39/test/OpenMP/target_parallel_for_simd_map_messages.cpp Wed Nov 23 15:29:33 2016
@@ -143,13 +143,13 @@ T tmain(T argc) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target parallel for simd map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
for (i = 0; i < argc; ++i) foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 4 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
{
#pragma omp target parallel for simd map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target parallel for simd map(j)
for (i = 0; i < argc; ++i) foo();
-#pragma omp target parallel for simd map(l) // expected-error 2 {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+#pragma omp target parallel for simd map(l)
for (i = 0; i < argc; ++i) foo();
}
@@ -247,13 +247,13 @@ int main(int argc, char **argv) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target parallel for simd map(l) map(l[:5]) // expected-error 1 {{variable already marked as mapped in current construct}} expected-note 1 {{used here}}
for (i = 0; i < argc; ++i) foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}}
{
#pragma omp target parallel for simd map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target parallel for simd map(j)
for (i = 0; i < argc; ++i) foo();
-#pragma omp target parallel for simd map(l) // expected-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+#pragma omp target parallel for simd map(l)
for (i = 0; i < argc; ++i) foo();
}
Modified: cfe/branches/release_39/test/OpenMP/target_parallel_map_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/OpenMP/target_parallel_map_messages.cpp?rev=287816&r1=287815&r2=287816&view=diff
==============================================================================
--- cfe/branches/release_39/test/OpenMP/target_parallel_map_messages.cpp (original)
+++ cfe/branches/release_39/test/OpenMP/target_parallel_map_messages.cpp Wed Nov 23 15:29:33 2016
@@ -143,13 +143,13 @@ T tmain(T argc) {
foo();
#pragma omp target parallel map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 4 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
{
#pragma omp target parallel map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
foo();
#pragma omp target parallel map(j)
foo();
-#pragma omp target parallel map(l) // expected-error 2 {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+#pragma omp target parallel map(l)
foo();
}
@@ -246,13 +246,13 @@ int main(int argc, char **argv) {
foo();
#pragma omp target parallel map(l) map(l[:5]) // expected-error 1 {{variable already marked as mapped in current construct}} expected-note 1 {{used here}}
foo();
-#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
+#pragma omp target data map(k[:4], j, l[:5]) // expected-note 1 {{used here}}
{
#pragma omp target parallel map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
foo();
#pragma omp target parallel map(j)
foo();
-#pragma omp target parallel map(l) // expected-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+#pragma omp target parallel map(l)
foo();
}
More information about the llvm-branch-commits
mailing list