diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 7a4c2a83c517..d301a4c16755 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(I->getAssociatedDeclaration())) { if (llvm::Optional 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 ad6718c67e2b..86c0c02bb211 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;