summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-01-16 02:22:55 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-01-16 02:22:55 +0000
commit67a79e72f5d210d42bfb2ff1f0ed7a695c2cd1ec (patch)
tree150b052c60eafa8cf3b8ac63750d15aedfa5d34c /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent15e9420f69933a9dc85dde62c481e5b9d3dea3e4 (diff)
downloadbcm5719-llvm-67a79e72f5d210d42bfb2ff1f0ed7a695c2cd1ec.tar.gz
bcm5719-llvm-67a79e72f5d210d42bfb2ff1f0ed7a695c2cd1ec.zip
Revert "Revert Don't create new comdats in CodeGen"
This reverts commit r226173, adding r226038 back. No change in this commit, but clang was changed to also produce trivial comdats for costructors, destructors and vtables when needed. Original message: Don't create new comdats in CodeGen. This patch stops the implicit creation of comdats during codegen. Clang now sets the comdat explicitly when it is required. With this patch clang and gcc now produce the same result in pr19848. llvm-svn: 226242
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp19
1 files changed, 5 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 9f1e06b4725..b9a3ad23d1f 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -257,8 +257,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
// If this global is linkonce/weak and the target handles this by emitting it
// into a 'uniqued' section name, create and return the section now.
- if ((GV->isWeakForLinker() || EmitUniquedSection || GV->hasComdat()) &&
- !Kind.isCommon()) {
+ if ((EmitUniquedSection && !Kind.isCommon()) || GV->hasComdat()) {
StringRef Prefix = getSectionPrefixForGlobal(Kind);
SmallString<128> Name(Prefix);
@@ -266,12 +265,9 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
StringRef Group = "";
unsigned Flags = getELFSectionFlags(Kind);
- if (GV->isWeakForLinker() || GV->hasComdat()) {
- if (const Comdat *C = getELFComdat(GV))
- Group = C->getName();
- else
- Group = Name.substr(Prefix.size());
+ if (const Comdat *C = getELFComdat(GV)) {
Flags |= ELF::SHF_GROUP;
+ Group = C->getName();
}
return getContext().getELFSection(Name.str(),
@@ -801,7 +797,7 @@ const MCSection *TargetLoweringObjectFileCOFF::getExplicitSectionGlobal(
unsigned Characteristics = getCOFFSectionFlags(Kind);
StringRef Name = GV->getSection();
StringRef COMDATSymName = "";
- if ((GV->isWeakForLinker() || GV->hasComdat()) && !Kind.isCommon()) {
+ if (GV->hasComdat()) {
Selection = getSelectionForCOFF(GV);
const GlobalValue *ComdatGV;
if (Selection == COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE)
@@ -848,12 +844,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
else
EmitUniquedSection = TM.getDataSections();
- // If this global is linkonce/weak and the target handles this by emitting it
- // into a 'uniqued' section name, create and return the section now.
- // Section names depend on the name of the symbol which is not feasible if the
- // symbol has private linkage.
- if ((GV->isWeakForLinker() || EmitUniquedSection || GV->hasComdat()) &&
- !Kind.isCommon()) {
+ if ((EmitUniquedSection && !Kind.isCommon()) || GV->hasComdat()) {
const char *Name = getCOFFSectionNameForUniqueGlobal(Kind);
unsigned Characteristics = getCOFFSectionFlags(Kind);
OpenPOWER on IntegriCloud