]> granicus.if.org Git - clang/commit
[patch][pr19848] Produce explicit comdats in clang.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 12 Jan 2015 22:13:53 +0000 (22:13 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 12 Jan 2015 22:13:53 +0000 (22:13 +0000)
commitc7bb1deeced2b512ff64b392e3e78c7604efa6c9
tree1458c9ffaf528f750c266d7827f6659deaa65f4c
parent7d651736be03cf173cfbbede99ed6f9c423a2c9e
[patch][pr19848] Produce explicit comdats in clang.

The llvm IR until recently had no support for comdats. This was a problem when
targeting C++ on ELF/COFF as just using weak linkage would cause quite a bit of
dead bits to remain on the executable (unless -ffunction-sections,
-fdata-sections and --gc-sections were used).

To fix the problem, llvm's codegen will just assume that any weak or linkonce
that is not in an explicit comdat should be output in one with the same name as
the global.

This unfortunately breaks cases like pr19848 where a weak symbol is not
xpected to be part of any comdat.

Now that we have explicit comdats in the IR, we can finally get both cases
right.

This first patch just makes clang give explicit comdats to GlobalValues where
t is allowed to.

A followup patch to llvm will then stop implicitly producing comdats.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225705 91177308-0d34-0410-b5e6-96231b3b80d8
14 files changed:
lib/CodeGen/CGDecl.cpp
lib/CodeGen/CGDeclCXX.cpp
lib/CodeGen/CodeGenModule.cpp
lib/CodeGen/ItaniumCXXABI.cpp
lib/CodeGen/MicrosoftCXXABI.cpp
test/CodeGen/ms-declspecs.c
test/CodeGenCXX/cxx11-exception-spec.cpp
test/CodeGenCXX/dllexport-members.cpp
test/CodeGenCXX/dllexport.cpp
test/CodeGenCXX/dllimport.cpp
test/CodeGenCXX/ms-integer-static-data-members-exported.cpp
test/CodeGenCXX/ms-integer-static-data-members.cpp
test/CodeGenCXX/split-stacks.cpp
test/CodeGenCXX/static-init.cpp