r330156 - [OPENMP] Allow to use declare target variables in map clauses
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 16 13:34:41 PDT 2018
Author: abataev
Date: Mon Apr 16 13:34:41 2018
New Revision: 330156
URL: http://llvm.org/viewvc/llvm-project?rev=330156&view=rev
Log:
[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.
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/declare_target_codegen.cpp
Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=330156&r1=330155&r2=330156&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon Apr 16 13:34:41 2018
@@ -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
Modified: cfe/trunk/test/OpenMP/declare_target_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_codegen.cpp?rev=330156&r1=330155&r2=330156&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/declare_target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_target_codegen.cpp Mon Apr 16 13:34:41 2018
@@ -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;
More information about the cfe-commits
mailing list