[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
This commit is contained in:
Alexey Bataev 2018-04-16 20:34:41 +00:00
parent 7c55265c2d
commit 2c1dffece6
2 changed files with 8 additions and 11 deletions

View File

@ -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

View File

@ -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;