[llvm] r228196 - Don' try to make sections in comdats SHF_MERGE.
Rafael Espindola
rafael.espindola at gmail.com
Wed Feb 4 13:27:24 PST 2015
Author: rafael
Date: Wed Feb 4 15:27:24 2015
New Revision: 228196
URL: http://llvm.org/viewvc/llvm-project?rev=228196&view=rev
Log:
Don' try to make sections in comdats SHF_MERGE.
Parts of llvm were not expecting it and we wouldn't print
the entity size of the section.
Given what comdats are used for, having SHF_MERGE sections would be
just a small improvement, so just disable it for now.
Fixes pr22463.
Added:
llvm/trunk/test/CodeGen/X86/global-sections-comdat.ll
Modified:
llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=228196&r1=228195&r2=228196&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Wed Feb 4 15:27:24 2015
@@ -166,7 +166,7 @@ static unsigned getELFSectionType(String
static unsigned
-getELFSectionFlags(SectionKind K) {
+getELFSectionFlags(SectionKind K, bool InCOMDAT) {
unsigned Flags = 0;
if (!K.isMetadata())
@@ -181,7 +181,7 @@ getELFSectionFlags(SectionKind K) {
if (K.isThreadLocal())
Flags |= ELF::SHF_TLS;
- if (K.isMergeableCString() || K.isMergeableConst())
+ if (!InCOMDAT && (K.isMergeableCString() || K.isMergeableConst()))
Flags |= ELF::SHF_MERGE;
if (K.isMergeableCString())
@@ -211,7 +211,7 @@ const MCSection *TargetLoweringObjectFil
Kind = getELFKindForNamedSection(SectionName, Kind);
StringRef Group = "";
- unsigned Flags = getELFSectionFlags(Kind);
+ unsigned Flags = getELFSectionFlags(Kind, GV->hasComdat());
if (const Comdat *C = getELFComdat(GV)) {
Group = C->getName();
Flags |= ELF::SHF_GROUP;
@@ -243,7 +243,7 @@ static StringRef getSectionPrefixForGlob
const MCSection *TargetLoweringObjectFileELF::
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
Mangler &Mang, const TargetMachine &TM) const {
- unsigned Flags = getELFSectionFlags(Kind);
+ unsigned Flags = getELFSectionFlags(Kind, GV->hasComdat());
// If we have -ffunction-section or -fdata-section then we should emit the
// global value to a uniqued section specifically for it.
Added: llvm/trunk/test/CodeGen/X86/global-sections-comdat.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/global-sections-comdat.ll?rev=228196&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/global-sections-comdat.ll (added)
+++ llvm/trunk/test/CodeGen/X86/global-sections-comdat.ll Wed Feb 4 15:27:24 2015
@@ -0,0 +1,8 @@
+; RUN: llc < %s -mtriple=i386-unknown-linux | FileCheck %s -check-prefix=LINUX
+; RUN: llc < %s -mtriple=i386-unknown-linux -data-sections | FileCheck %s -check-prefix=LINUX-SECTIONS
+
+$G16 = comdat any
+ at G16 = unnamed_addr constant i32 42, comdat
+
+; LINUX: .section .rodata.G16,"aG", at progbits,G16,comdat
+; LINUX-SECTIONS: .section .rodata.G16,"aG", at progbits,G16,comdat
More information about the llvm-commits
mailing list