[PATCH] D29843: [CodeGen] Treat auto-generated __dso_handle symbol as HiddenVisibility

Roland McGrath via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 10 15:17:39 PST 2017


mcgrathr updated this revision to Diff 88064.

https://reviews.llvm.org/D29843

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp


Index: lib/CodeGen/ItaniumCXXABI.cpp
===================================================================
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2162,7 +2162,7 @@
 
   // Create a variable that binds the atexit to this shared object.
   llvm::Constant *handle =
-    CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
+    CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle", true);
 
   llvm::Value *args[] = {
     llvm::ConstantExpr::getBitCast(dtor, dtorTy),
Index: lib/CodeGen/CodeGenModule.h
===================================================================
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -916,7 +916,8 @@
                                           llvm::AttributeSet());
   /// Create a new runtime global variable with the specified type and name.
   llvm::Constant *CreateRuntimeVariable(llvm::Type *Ty,
-                                        StringRef Name);
+                                        StringRef Name,
+                                        bool Hidden = false);
 
   ///@name Custom Blocks Runtime Interfaces
   ///@{
@@ -1220,7 +1221,8 @@
                                         llvm::PointerType *PTy,
                                         const VarDecl *D,
                                         ForDefinition_t IsForDefinition
-                                          = NotForDefinition);
+                                          = NotForDefinition,
+                                        bool Hidden = false);
 
   void setNonAliasAttributes(const Decl *D, llvm::GlobalObject *GO);
 
Index: lib/CodeGen/CodeGenModule.cpp
===================================================================
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2183,7 +2183,8 @@
 CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
                                      llvm::PointerType *Ty,
                                      const VarDecl *D,
-                                     ForDefinition_t IsForDefinition) {
+                                     ForDefinition_t IsForDefinition,
+                                     bool Hidden) {
   // Lookup the entry, lazily creating it if necessary.
   llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
   if (Entry) {
@@ -2288,6 +2289,8 @@
         D->getType().isConstant(Context) &&
         isExternallyVisible(D->getLinkageAndVisibility().getLinkage()))
       GV->setSection(".cp.rodata");
+  } else if (Hidden) {
+    GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
   }
 
   if (AddrSpace != Ty->getAddressSpace())
@@ -2393,8 +2396,10 @@
 /// specified type and name.
 llvm::Constant *
 CodeGenModule::CreateRuntimeVariable(llvm::Type *Ty,
-                                     StringRef Name) {
-  return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), nullptr);
+                                     StringRef Name,
+                                     bool Hidden) {
+  return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), nullptr,
+                               NotForDefinition, Hidden);
 }
 
 void CodeGenModule::EmitTentativeDefinition(const VarDecl *D) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29843.88064.patch
Type: text/x-patch
Size: 3207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170210/307dd8b0/attachment.bin>


More information about the cfe-commits mailing list