Reid, didn't you add something like this for COFF?<div><br></div><div>Sent from my phone<span></span><br><br>On Sunday, June 26, 2016, Dean Michael Berris via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">dberris created this revision.<br>
dberris added reviewers: echristo, grosbach.<br>
dberris added a subscriber: llvm-commits.<br>
Herald added a subscriber: mehdi_amini.<br>
<br>
This change allows us to create uniquely identified "COMDAT" or "ELF<br>
Group" sections while lowering. In particular, for ELF sections this is<br>
useful for creating function-specific groups that get merged into the<br>
same named section.<br>
<br>
<a href="http://reviews.llvm.org/D21743" target="_blank">http://reviews.llvm.org/D21743</a><br>
<br>
Files:<br>
  include/llvm/MC/MCELFStreamer.h<br>
  include/llvm/MC/MCStreamer.h<br>
  lib/MC/MCELFStreamer.cpp<br>
  lib/MC/MCStreamer.cpp<br>
<br>
Index: lib/MC/MCStreamer.cpp<br>
===================================================================<br>
--- lib/MC/MCStreamer.cpp<br>
+++ lib/MC/MCStreamer.cpp<br>
@@ -806,3 +806,8 @@<br>
   EmitLabel(Sym);<br>
   return Sym;<br>
 }<br>
+<br>
+MCSection *MCStreamer::getNamedGroupSection(StringRef, StringRef, unsigned) {<br>
+  llvm_unreachable("Unimplemented.");<br>
+  return nullptr;<br>
+}<br>
Index: lib/MC/MCELFStreamer.cpp<br>
===================================================================<br>
--- lib/MC/MCELFStreamer.cpp<br>
+++ lib/MC/MCELFStreamer.cpp<br>
@@ -672,3 +672,11 @@<br>
                                    uint64_t Size, unsigned ByteAlignment) {<br>
   llvm_unreachable("ELF doesn't support this directive");<br>
 }<br>
+<br>
+MCSection *MCELFStreamer::getNamedGroupSection(StringRef Section,<br>
+                                               StringRef Identifier,<br>
+                                               unsigned EntSize) {<br>
+  return getContext().getELFSection(Section, ELF::SHT_PROGBITS,<br>
+                                    ELF::SHF_ALLOC | ELF::SHF_GROUP, EntSize,<br>
+                                    Identifier);<br>
+}<br>
Index: include/llvm/MC/MCStreamer.h<br>
===================================================================<br>
--- include/llvm/MC/MCStreamer.h<br>
+++ include/llvm/MC/MCStreamer.h<br>
@@ -760,6 +760,12 @@<br>
   /// Get the .xdata section used for the given section.<br>
   MCSection *getAssociatedXDataSection(const MCSection *TextSec);<br>
<br>
+  /// Get a group section with provided group identifier. This is in ELF, for<br>
+  /// instance, named by concatenating \p Section with '.' then \p Identifier.<br>
+  virtual MCSection *getNamedGroupSection(StringRef Section,<br>
+                                          StringRef Identifier,<br>
+                                          unsigned EntSize);<br>
+<br>
   virtual void EmitSyntaxDirective();<br>
<br>
   /// \brief Emit a .reloc directive.<br>
Index: include/llvm/MC/MCELFStreamer.h<br>
===================================================================<br>
--- include/llvm/MC/MCELFStreamer.h<br>
+++ include/llvm/MC/MCELFStreamer.h<br>
@@ -81,6 +81,9 @@<br>
   void EmitBundleLock(bool AlignToEnd) override;<br>
   void EmitBundleUnlock() override;<br>
<br>
+  MCSection *getNamedGroupSection(StringRef Section, StringRef Identifer,<br>
+                                  unsigned EntSize) override;<br>
+<br>
 private:<br>
   bool isBundleLocked() const;<br>
   void EmitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override;<br>
<br>
<br>
</blockquote></div>