[PATCH] D21743: Convenience function for MCContext to get named sections when lowering.

Dean Michael Berris via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 29 18:47:53 PDT 2016


dberris updated this revision to Diff 62326.
dberris added a comment.

- Rename "Section" -> "Prefix", "Group" -> "Suffix"


http://reviews.llvm.org/D21743

Files:
  include/llvm/MC/MCContext.h
  lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  lib/MC/MCContext.cpp

Index: lib/MC/MCContext.cpp
===================================================================
--- lib/MC/MCContext.cpp
+++ lib/MC/MCContext.cpp
@@ -322,6 +322,15 @@
                    EntrySize, Group, true, nullptr, Associated);
 }
 
+MCSectionELF *MCContext::getELFNamedSection(StringRef Prefix, StringRef Suffix,
+                                            unsigned Type, unsigned Flags,
+                                            unsigned EntrySize) {
+  SmallString<64> FullName(Prefix);
+  FullName += ".";
+  FullName += Suffix;
+  return getELFSection(FullName, Type, Flags, EntrySize, Suffix);
+}
+
 MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
                                        unsigned Flags, unsigned EntrySize,
                                        StringRef Group, unsigned UniqueID,
Index: lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -69,11 +69,9 @@
       cast<MCSymbolELF>(getContext().getOrCreateSymbol(NameData));
   Streamer.EmitSymbolAttribute(Label, MCSA_Hidden);
   Streamer.EmitSymbolAttribute(Label, MCSA_Weak);
-  StringRef Prefix = ".data.";
-  NameData.insert(NameData.begin(), Prefix.begin(), Prefix.end());
   unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_WRITE | ELF::SHF_GROUP;
-  MCSection *Sec = getContext().getELFSection(NameData, ELF::SHT_PROGBITS,
-                                              Flags, 0, Label->getName());
+  MCSection *Sec = getContext().getELFNamedSection(".data", Label->getName(),
+                                                   ELF::SHT_PROGBITS, Flags, 0);
   unsigned Size = DL.getPointerSize();
   Streamer.SwitchSection(Sec);
   Streamer.EmitValueToAlignment(DL.getPointerABIAlignment());
Index: include/llvm/MC/MCContext.h
===================================================================
--- include/llvm/MC/MCContext.h
+++ include/llvm/MC/MCContext.h
@@ -380,6 +380,14 @@
                                 const char *BeginSymName,
                                 const MCSectionELF *Associated);
 
+    /// Get a section with the provided group identifier. This section is
+    /// named by concatenating \p Prefix with '.' then \p Suffix. The \p Type
+    /// describes the type of the section and \p Flags are used to further
+    /// configure this named section.
+    MCSectionELF *getELFNamedSection(StringRef Prefix, StringRef Suffix,
+                                     unsigned Type, unsigned Flags,
+                                     unsigned EntrySize = 0);
+
     MCSectionELF *createELFRelSection(StringRef Name, unsigned Type,
                                       unsigned Flags, unsigned EntrySize,
                                       const MCSymbolELF *Group,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21743.62326.patch
Type: text/x-patch
Size: 2869 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160630/24f6a96a/attachment.bin>


More information about the llvm-commits mailing list