[PATCH] D50783: [CodeGen] Merge identical block descriptor global variables

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 16 16:24:40 PDT 2018


ahatanak added inline comments.


================
Comment at: lib/CodeGen/CGBlocks.cpp:271-276
   llvm::GlobalVariable *global =
-    elements.finishAndCreateGlobal("__block_descriptor_tmp",
-                                   CGM.getPointerAlign(),
-                                   /*constant*/ true,
-                                   llvm::GlobalValue::InternalLinkage,
-                                   AddrSpace);
+      elements.finishAndCreateGlobal(descName, CGM.getPointerAlign(),
+                                     /*constant*/ true, linkage, AddrSpace);
+
+  if (linkage == llvm::GlobalValue::LinkOnceODRLinkage)
+    global->setVisibility(llvm::GlobalValue::HiddenVisibility);
----------------
rsmith wrote:
> Would it make sense to also mark this constant as `unnamed_addr`?
Yes. I don't think there is any harm in marking it as `unnamed_addr`. However, unfortunately it looks like ld64 doesn't try to merge `unnamed_addr` global variables.


Repository:
  rC Clang

https://reviews.llvm.org/D50783





More information about the cfe-commits mailing list