[PATCH] D58807: [CodeGen] COMDAT-fold block descriptors

Dustin L. Howett via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 28 18:09:52 PST 2019


DHowett-MSFT created this revision.
DHowett-MSFT added a project: clang.
Herald added a subscriber: cfe-commits.

Without this change, linking multiple objects containing block
descriptors together on Windows will generate duplicate symbol errors.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58807

Files:
  clang/lib/CodeGen/CGBlocks.cpp


Index: clang/lib/CodeGen/CGBlocks.cpp
===================================================================
--- clang/lib/CodeGen/CGBlocks.cpp
+++ clang/lib/CodeGen/CGBlocks.cpp
@@ -274,6 +274,8 @@
                                      /*constant*/ true, linkage, AddrSpace);
 
   if (linkage == llvm::GlobalValue::LinkOnceODRLinkage) {
+    if (CGM.supportsCOMDAT())
+      global->setComdat(CGM.getModule().getOrInsertComdat(descName));
     global->setVisibility(llvm::GlobalValue::HiddenVisibility);
     global->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58807.188828.patch
Type: text/x-patch
Size: 576 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190301/1d6b97e2/attachment.bin>


More information about the cfe-commits mailing list