diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -2179,11 +2179,14 @@ return &*Elem.second; } - return Elem.second = new llvm::GlobalVariable( - CGM.getModule(), Ty, /*IsConstant*/ false, - llvm::GlobalValue::CommonLinkage, llvm::Constant::getNullValue(Ty), - Elem.first(), /*InsertBefore=*/nullptr, - llvm::GlobalValue::NotThreadLocal, AddressSpace); + llvm::GlobalVariable *GV = new llvm::GlobalVariable( + CGM.getModule(), Ty, /*IsConstant*/ false, + llvm::GlobalValue::CommonLinkage, llvm::Constant::getNullValue(Ty), + Elem.first(), /*InsertBefore=*/nullptr, llvm::GlobalValue::NotThreadLocal, + AddressSpace); + GV->setDSOLocal(true); + Elem.second = GV; + return Elem.second; } llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) {