summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-03-25 06:14:26 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-03-25 06:14:26 +0000
commit273bff4713735f8a2324addf876d9b59e4243023 (patch)
tree78ecb023d6998334dc46c6ac1be21c6d2870bf6e /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent3ffe4dd67f004ff4fa9d563f957889288519a243 (diff)
downloadbcm5719-llvm-273bff4713735f8a2324addf876d9b59e4243023.tar.gz
bcm5719-llvm-273bff4713735f8a2324addf876d9b59e4243023.zip
WinCOFF: Add support for -fdata-sections
This is a pretty straight forward translation for COFF, we just need to stick the data in a COMDAT section marked as IMAGE_COMDAT_SELECT_NODUPLICATES. N.B. We must be careful to avoid sticking entities with private linkage in COMDAT groups. COFF is pretty hostile to the renaming of entities so we must be careful to disallow GlobalVariables with unstable names. llvm-svn: 204703
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 8f113d79162..e41fbfc6d36 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -770,12 +770,18 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
Mangler &Mang, const TargetMachine &TM) const {
// If we have -ffunction-sections then we should emit the global value to a
// uniqued section specifically for it.
- // TODO: Implement -fdata-sections.
- bool EmitUniquedSection = Kind.isText() && TM.getFunctionSections();
+ bool EmitUniquedSection;
+ if (Kind.isText())
+ EmitUniquedSection = TM.getFunctionSections();
+ 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.
- if (GV->isWeakForLinker() || EmitUniquedSection) {
+ // Section names depend on the name of the symbol which is not feasible if the
+ // symbol has private linkage.
+ if ((GV->isWeakForLinker() || EmitUniquedSection) &&
+ !GV->hasPrivateLinkage()) {
const char *Name = getCOFFSectionNameForUniqueGlobal(Kind);
unsigned Characteristics = getCOFFSectionFlags(Kind);
OpenPOWER on IntegriCloud