Index: lib/CodeGen/CGOpenMPRuntime.cpp =================================================================== --- lib/CodeGen/CGOpenMPRuntime.cpp +++ lib/CodeGen/CGOpenMPRuntime.cpp @@ -2572,7 +2572,7 @@ PtrName); if (!CGM.getLangOpts().OpenMPIsDevice) { auto *GV = cast(Ptr); - GV->setLinkage(llvm::GlobalValue::ExternalLinkage); + GV->setLinkage(llvm::GlobalValue::WeakAnyLinkage); GV->setInitializer(CGM.GetAddrOfGlobal(VD)); } CGM.addUsedGlobal(cast(Ptr)); Index: test/OpenMP/declare_target_link_codegen.cpp =================================================================== --- test/OpenMP/declare_target_link_codegen.cpp +++ test/OpenMP/declare_target_link_codegen.cpp @@ -18,7 +18,7 @@ #define HEADER // HOST-DAG: @c = external global i32, -// HOST-DAG: @c_decl_tgt_ref_ptr = global i32* @c +// HOST-DAG: @c_decl_tgt_ref_ptr = weak global i32* @c // DEVICE-NOT: @c = // DEVICE: @c_decl_tgt_ref_ptr = common global i32* null // HOST: [[SIZES:@.+]] = private unnamed_addr constant [2 x i64] [i64 4, i64 4] Index: test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp =================================================================== --- test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp +++ test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp @@ -31,10 +31,10 @@ } // CHECK-HOST: [[VAR:@.+]] = global double 1.000000e+01 -// CHECK-HOST: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]] +// CHECK-HOST: [[VAR_DECL_TGT_LINK_PTR:@.+]] = weak global double* [[VAR]] // CHECK-HOST: [[TO_VAR:@.+]] = global double 2.000000e+01 -// CHECK-HOST: [[VAR_DECL_TGT_TO_PTR:@.+]] = global double* [[TO_VAR]] +// CHECK-HOST: [[VAR_DECL_TGT_TO_PTR:@.+]] = weak global double* [[TO_VAR]] // CHECK-HOST: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [2 x i64] [i64 4, i64 8] // CHECK-HOST: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [2 x i64] [i64 800, i64 800]