diff options
| author | Alexey Bataev <a.bataev@hotmail.com> | 2018-04-16 20:34:41 +0000 |
|---|---|---|
| committer | Alexey Bataev <a.bataev@hotmail.com> | 2018-04-16 20:34:41 +0000 |
| commit | 2c1dffece66610e30cc71b710b52f855a3738e43 (patch) | |
| tree | f7da8421d34e255691aade126b8e2e7525250f4a | |
| parent | 7c55265c2dfad74f91530f86a61357e22a472dfa (diff) | |
| download | bcm5719-llvm-2c1dffece66610e30cc71b710b52f855a3738e43.tar.gz bcm5719-llvm-2c1dffece66610e30cc71b710b52f855a3738e43.zip | |
[OPENMP] Allow to use declare target variables in map clauses
Global variables marked as declare target are allowed to be used in map
clauses. Patch fixes the crash of the compiler on the declare target
variables in map clauses.
llvm-svn: 330156
| -rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntime.cpp | 17 | ||||
| -rw-r--r-- | clang/test/OpenMP/declare_target_codegen.cpp | 2 |
2 files changed, 8 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 7a4c2a83c51..d301a4c1675 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -6799,16 +6799,13 @@ public: if (const auto *VD = dyn_cast_or_null<VarDecl>(I->getAssociatedDeclaration())) { if (llvm::Optional<OMPDeclareTargetDeclAttr::MapTypeTy> Res = - isDeclareTargetDeclaration(VD)) { - assert(*Res == OMPDeclareTargetDeclAttr::MT_Link && - "Declare target link is expected."); - // Avoid warning in release build. - (void)*Res; - IsLink = true; - BP = CGF.CGM.getOpenMPRuntime() - .getAddrOfDeclareTargetLink(VD) - .getPointer(); - } + isDeclareTargetDeclaration(VD)) + if (*Res == OMPDeclareTargetDeclAttr::MT_Link) { + IsLink = true; + BP = CGF.CGM.getOpenMPRuntime() + .getAddrOfDeclareTargetLink(VD) + .getPointer(); + } } // If the variable is a pointer and is being dereferenced (i.e. is not diff --git a/clang/test/OpenMP/declare_target_codegen.cpp b/clang/test/OpenMP/declare_target_codegen.cpp index ad6718c67e2..86c0c02bb21 100644 --- a/clang/test/OpenMP/declare_target_codegen.cpp +++ b/clang/test/OpenMP/declare_target_codegen.cpp @@ -45,7 +45,7 @@ int maini1() { static long aa = 32; // CHECK-DAG: define void @__omp_offloading_{{.*}}maini1{{.*}}_l[[@LINE+1]](i32* dereferenceable{{.*}}, i64 {{.*}}, i64 {{.*}}) #pragma omp target map(tofrom \ - : a) + : a, b) { static long aaa = 23; a = foo() + bar() + b + c + d + aa + aaa; |

