kamleshbhalui created this revision.
kamleshbhalui added reviewers: MaskRay, pengfei.
kamleshbhalui added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
kamleshbhalui requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Starting from clang-12 openmp started generating internal global variable with 
got relocation even when static relocation  enabled.
In clang-11 shouldAssumeDSOLocal was assuming it dso_local based on static 
relocation model.
Since shouldAssumeDSOLocal  is cleaned up now for respecting dso_local  
generated from frontend, marking openmp internal globals as dso_local.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108421

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===================================================================
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2179,11 +2179,14 @@
     return &*Elem.second;
   }
 
-  return Elem.second = new llvm::GlobalVariable(
+  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) {


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===================================================================
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2179,11 +2179,14 @@
     return &*Elem.second;
   }
 
-  return Elem.second = new llvm::GlobalVariable(
+  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) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to