diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-03-23 17:47:39 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-03-23 17:47:39 +0000 |
commit | 9338984f57f28634b480d5940801a78667a25058 (patch) | |
tree | 619d0cbcc8f041343c58b27e9d3a7c9c6d71c6f0 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | |
parent | da39ab299a656b763a31b7ceb7e5f1fef74786e8 (diff) | |
download | llvm-9338984f57f28634b480d5940801a78667a25058.zip llvm-9338984f57f28634b480d5940801a78667a25058.tar.gz llvm-9338984f57f28634b480d5940801a78667a25058.tar.bz2 |
WinCOFF: Add support for -ffunction-sections
This is a pretty straight forward translation for COFF, we just need to
stick the function in a COMDAT section marked as
IMAGE_COMDAT_SELECT_NODUPLICATES.
llvm-svn: 204565
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index a2f4810..8f113d7 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -768,18 +768,23 @@ static const char *getCOFFSectionNameForUniqueGlobal(SectionKind Kind) { const MCSection *TargetLoweringObjectFileCOFF:: 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(); // 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()) { + if (GV->isWeakForLinker() || EmitUniquedSection) { const char *Name = getCOFFSectionNameForUniqueGlobal(Kind); unsigned Characteristics = getCOFFSectionFlags(Kind); Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT; MCSymbol *Sym = TM.getSymbol(GV, Mang); - return getContext().getCOFFSection(Name, Characteristics, - Kind, Sym->getName(), - COFF::IMAGE_COMDAT_SELECT_ANY); + return getContext().getCOFFSection( + Name, Characteristics, Kind, Sym->getName(), + GV->isWeakForLinker() ? COFF::IMAGE_COMDAT_SELECT_ANY + : COFF::IMAGE_COMDAT_SELECT_NODUPLICATES); } if (Kind.isText()) |