<div dir="ltr">Can you go ahead and add a FIXME here? It's conceivable that we'll want SHF_MERGE sections to be part of a comdat.<br><br>-eric<br></div><br><div class="gmail_quote">On Wed Feb 04 2015 at 1:35:53 PM Rafael Espindola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rafael<br>
Date: Wed Feb  4 15:27:24 2015<br>
New Revision: 228196<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=228196&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project?rev=228196&view=rev</a><br>
Log:<br>
Don' try to make sections in comdats SHF_MERGE.<br>
<br>
Parts of llvm were not expecting it and we wouldn't print<br>
the entity size of the section.<br>
<br>
Given what comdats are used for, having SHF_MERGE sections would be<br>
just a small improvement, so just disable it for now.<br>
<br>
Fixes pr22463.<br>
<br>
Added:<br>
    llvm/trunk/test/CodeGen/X86/<u></u>global-sections-comdat.ll<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/<u></u>TargetLoweringObjectFileImpl.<u></u>cpp<br>
<br>
Modified: llvm/trunk/lib/CodeGen/<u></u>TargetLoweringObjectFileImpl.<u></u>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=228196&r1=228195&r2=228196&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/llvm/trunk/lib/<u></u>CodeGen/<u></u>TargetLoweringObjectFileImpl.<u></u>cpp?rev=228196&r1=228195&r2=<u></u>228196&view=diff</a><br>
==============================<u></u>==============================<u></u>==================<br>
--- llvm/trunk/lib/CodeGen/<u></u>TargetLoweringObjectFileImpl.<u></u>cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/<u></u>TargetLoweringObjectFileImpl.<u></u>cpp Wed Feb  4 15:27:24 2015<br>
@@ -166,7 +166,7 @@ static unsigned getELFSectionType(String<br>
<br>
<br>
 static unsigned<br>
-getELFSectionFlags(<u></u>SectionKind K) {<br>
+getELFSectionFlags(<u></u>SectionKind K, bool InCOMDAT) {<br>
   unsigned Flags = 0;<br>
<br>
   if (!K.isMetadata())<br>
@@ -181,7 +181,7 @@ getELFSectionFlags(SectionKind K) {<br>
   if (K.isThreadLocal())<br>
     Flags |= ELF::SHF_TLS;<br>
<br>
-  if (K.isMergeableCString() || K.isMergeableConst())<br>
+  if (!InCOMDAT && (K.isMergeableCString() || K.isMergeableConst()))<br>
     Flags |= ELF::SHF_MERGE;<br>
<br>
   if (K.isMergeableCString())<br>
@@ -211,7 +211,7 @@ const MCSection *TargetLoweringObjectFil<br>
   Kind = getELFKindForNamedSection(<u></u>SectionName, Kind);<br>
<br>
   StringRef Group = "";<br>
-  unsigned Flags = getELFSectionFlags(Kind);<br>
+  unsigned Flags = getELFSectionFlags(Kind, GV->hasComdat());<br>
   if (const Comdat *C = getELFComdat(GV)) {<br>
     Group = C->getName();<br>
     Flags |= ELF::SHF_GROUP;<br>
@@ -243,7 +243,7 @@ static StringRef getSectionPrefixForGlob<br>
 const MCSection *TargetLoweringObjectFileELF::<br>
 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,<br>
                        Mangler &Mang, const TargetMachine &TM) const {<br>
-  unsigned Flags = getELFSectionFlags(Kind);<br>
+  unsigned Flags = getELFSectionFlags(Kind, GV->hasComdat());<br>
<br>
   // If we have -ffunction-section or -fdata-section then we should emit the<br>
   // global value to a uniqued section specifically for it.<br>
<br>
Added: llvm/trunk/test/CodeGen/X86/<u></u>global-sections-comdat.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/global-sections-comdat.ll?rev=228196&view=auto" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/llvm/trunk/test/<u></u>CodeGen/X86/global-sections-<u></u>comdat.ll?rev=228196&view=auto</a><br>
==============================<u></u>==============================<u></u>==================<br>
--- llvm/trunk/test/CodeGen/X86/<u></u>global-sections-comdat.ll (added)<br>
+++ llvm/trunk/test/CodeGen/X86/<u></u>global-sections-comdat.ll Wed Feb  4 15:27:24 2015<br>
@@ -0,0 +1,8 @@<br>
+; RUN: llc < %s -mtriple=i386-unknown-linux | FileCheck %s -check-prefix=LINUX<br>
+; RUN: llc < %s -mtriple=i386-unknown-linux -data-sections | FileCheck %s -check-prefix=LINUX-SECTIONS<br>
+<br>
+$G16 = comdat any<br>
+@G16 = unnamed_addr constant i32 42, comdat<br>
+<br>
+; LINUX: .section      .rodata.G16,"aG",@progbits,<u></u>G16,comdat<br>
+; LINUX-SECTIONS: .section     .rodata.G16,"aG",@progbits,<u></u>G16,comdat<br>
<br>
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
</blockquote></div>