[llvm] r313058 - [WebAssembly] Remove flags from MCSectionWasm

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 12 11:31:25 PDT 2017


Author: sbc
Date: Tue Sep 12 11:31:24 2017
New Revision: 313058

URL: http://llvm.org/viewvc/llvm-project?rev=313058&view=rev
Log:
[WebAssembly] Remove flags from MCSectionWasm

Looks like these were copied from the ELF sections but
don't apply to Wasm and were not used anywhere.

Also remove unused Wasm methods in MCContext.

Differential Revision: https://reviews.llvm.org/D37633

Modified:
    llvm/trunk/include/llvm/MC/MCContext.h
    llvm/trunk/include/llvm/MC/MCSectionWasm.h
    llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
    llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
    llvm/trunk/lib/MC/MCContext.cpp
    llvm/trunk/lib/MC/MCObjectFileInfo.cpp

Modified: llvm/trunk/include/llvm/MC/MCContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=313058&r1=313057&r2=313058&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCContext.h (original)
+++ llvm/trunk/include/llvm/MC/MCContext.h Tue Sep 12 11:31:24 2017
@@ -441,53 +441,27 @@ namespace llvm {
     getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym,
                               unsigned UniqueID = GenericSectionID);
 
-    MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
-                                  unsigned Flags) {
-      return getWasmSection(Section, Type, Flags, nullptr);
+    MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type) {
+      return getWasmSection(Section, Type, nullptr);
     }
 
     MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
-                                  unsigned Flags, const char *BeginSymName) {
-      return getWasmSection(Section, Type, Flags, "", BeginSymName);
-    }
-
-    MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
-                                  unsigned Flags, const Twine &Group) {
-      return getWasmSection(Section, Type, Flags, Group, nullptr);
-    }
-
-    MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
-                                  unsigned Flags, const Twine &Group,
                                   const char *BeginSymName) {
-      return getWasmSection(Section, Type, Flags, Group, ~0, BeginSymName);
+      return getWasmSection(Section, Type, "", ~0, BeginSymName);
     }
 
     MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
-                                  unsigned Flags, const Twine &Group,
-                                  unsigned UniqueID) {
-      return getWasmSection(Section, Type, Flags, Group, UniqueID, nullptr);
+                                  const Twine &Group, unsigned UniqueID) {
+      return getWasmSection(Section, Type, Group, UniqueID, nullptr);
     }
 
     MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
-                                  unsigned Flags, const Twine &Group,
-                                  unsigned UniqueID, const char *BeginSymName);
+                                  const Twine &Group, unsigned UniqueID,
+                                  const char *BeginSymName);
 
     MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
-                                  unsigned Flags, const MCSymbolWasm *Group,
-                                  unsigned UniqueID, const char *BeginSymName);
-
-    /// 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.
-    MCSectionWasm *getWasmNamedSection(const Twine &Prefix, const Twine &Suffix,
-                                       unsigned Type, unsigned Flags);
-
-    MCSectionWasm *createWasmRelSection(const Twine &Name, unsigned Type,
-                                        unsigned Flags,
-                                        const MCSymbolWasm *Group);
-
-    void renameWasmSection(MCSectionWasm *Section, StringRef Name);
+                                  const MCSymbolWasm *Group, unsigned UniqueID,
+                                  const char *BeginSymName);
 
     // Create and save a copy of STI and return a reference to the copy.
     MCSubtargetInfo &getSubtargetCopy(const MCSubtargetInfo &STI);

Modified: llvm/trunk/include/llvm/MC/MCSectionWasm.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSectionWasm.h?rev=313058&r1=313057&r2=313058&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCSectionWasm.h (original)
+++ llvm/trunk/include/llvm/MC/MCSectionWasm.h Tue Sep 12 11:31:24 2017
@@ -31,12 +31,9 @@ private:
   /// TargetLoweringObjectFileWasm's WasmUniqueMap.
   StringRef SectionName;
 
-  /// This is the sh_type field of a section, drawn from the enums below.
+  /// This is the type of the section, from the enums in BinaryFormat/Wasm.h
   unsigned Type;
 
-  /// This is the sh_flags field of a section, drawn from the enums below.
-  unsigned Flags;
-
   unsigned UniqueID;
 
   const MCSymbolWasm *Group;
@@ -47,11 +44,10 @@ private:
   uint64_t SectionOffset;
 
   friend class MCContext;
-  MCSectionWasm(StringRef Section, unsigned type, unsigned flags, SectionKind K,
+  MCSectionWasm(StringRef Section, unsigned type, SectionKind K,
                 const MCSymbolWasm *group, unsigned UniqueID, MCSymbol *Begin)
       : MCSection(SV_Wasm, K, Begin), SectionName(Section), Type(type),
-        Flags(flags), UniqueID(UniqueID), Group(group), SectionOffset(0) {
-  }
+        UniqueID(UniqueID), Group(group), SectionOffset(0) {}
 
   void setSectionName(StringRef Name) { SectionName = Name; }
 
@@ -64,8 +60,6 @@ public:
 
   StringRef getSectionName() const { return SectionName; }
   unsigned getType() const { return Type; }
-  unsigned getFlags() const { return Flags; }
-  void setFlags(unsigned F) { Flags = F; }
   const MCSymbolWasm *getGroup() const { return Group; }
 
   void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,

Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=313058&r1=313057&r2=313058&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Tue Sep 12 11:31:24 2017
@@ -47,10 +47,10 @@ protected:
   bool SupportGOTPCRelWithOffset = true;
 
   /// This section contains the static constructor pointer list.
-  MCSection *StaticCtorSection;
+  MCSection *StaticCtorSection = nullptr;
 
   /// This section contains the static destructor pointer list.
-  MCSection *StaticDtorSection;
+  MCSection *StaticDtorSection = nullptr;
 
 public:
   TargetLoweringObjectFile() = default;

Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=313058&r1=313057&r2=313058&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Tue Sep 12 11:31:24 2017
@@ -1252,11 +1252,9 @@ MCSection *TargetLoweringObjectFileWasm:
   return nullptr;
 }
 
-static MCSectionWasm *
-selectWasmSectionForGlobal(MCContext &Ctx, const GlobalObject *GO,
-                           SectionKind Kind, Mangler &Mang,
-                           const TargetMachine &TM, bool EmitUniqueSection,
-                           unsigned Flags, unsigned *NextUniqueID) {
+static MCSectionWasm *selectWasmSectionForGlobal(
+    MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang,
+    const TargetMachine &TM, bool EmitUniqueSection, unsigned *NextUniqueID) {
   StringRef Group = "";
   if (getWasmComdat(GO))
     llvm_unreachable("comdat not yet supported for wasm");
@@ -1279,8 +1277,7 @@ selectWasmSectionForGlobal(MCContext &Ct
     UniqueID = *NextUniqueID;
     (*NextUniqueID)++;
   }
-  return Ctx.getWasmSection(Name, /*Type=*/0, Flags,
-                            Group, UniqueID);
+  return Ctx.getWasmSection(Name, /*Type=*/0, Group, UniqueID);
 }
 
 MCSection *TargetLoweringObjectFileWasm::SelectSectionForGlobal(
@@ -1299,8 +1296,7 @@ MCSection *TargetLoweringObjectFileWasm:
   EmitUniqueSection |= GO->hasComdat();
 
   return selectWasmSectionForGlobal(getContext(), GO, Kind, getMangler(), TM,
-                                    EmitUniqueSection, /*Flags=*/0,
-                                    &NextUniqueID);
+                                    EmitUniqueSection, &NextUniqueID);
 }
 
 bool TargetLoweringObjectFileWasm::shouldPutJumpTableInFunctionSection(

Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=313058&r1=313057&r2=313058&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Tue Sep 12 11:31:24 2017
@@ -486,53 +486,17 @@ MCSectionCOFF *MCContext::getAssociative
                         "", 0, UniqueID);
 }
 
-void MCContext::renameWasmSection(MCSectionWasm *Section, StringRef Name) {
-  StringRef GroupName;
-  assert(!Section->getGroup() && "not yet implemented");
-
-  unsigned UniqueID = Section->getUniqueID();
-  WasmUniquingMap.erase(
-      WasmSectionKey{Section->getSectionName(), GroupName, UniqueID});
-  auto I = WasmUniquingMap.insert(std::make_pair(
-                                     WasmSectionKey{Name, GroupName, UniqueID},
-                                     Section))
-               .first;
-  StringRef CachedName = I->first.SectionName;
-  const_cast<MCSectionWasm *>(Section)->setSectionName(CachedName);
-}
-
-MCSectionWasm *MCContext::createWasmRelSection(const Twine &Name, unsigned Type,
-                                               unsigned Flags,
-                                               const MCSymbolWasm *Group) {
-  StringMap<bool>::iterator I;
-  bool Inserted;
-  std::tie(I, Inserted) =
-      RelSecNames.insert(std::make_pair(Name.str(), true));
-
-  return new (WasmAllocator.Allocate())
-      MCSectionWasm(I->getKey(), Type, Flags, SectionKind::getReadOnly(),
-                    Group, ~0, nullptr);
-}
-
-MCSectionWasm *MCContext::getWasmNamedSection(const Twine &Prefix,
-                                              const Twine &Suffix, unsigned Type,
-                                              unsigned Flags) {
-  return getWasmSection(Prefix + "." + Suffix, Type, Flags, Suffix);
-}
-
 MCSectionWasm *MCContext::getWasmSection(const Twine &Section, unsigned Type,
-                                         unsigned Flags,
                                          const Twine &Group, unsigned UniqueID,
                                          const char *BeginSymName) {
   MCSymbolWasm *GroupSym = nullptr;
   if (!Group.isTriviallyEmpty() && !Group.str().empty())
     GroupSym = cast<MCSymbolWasm>(getOrCreateSymbol(Group));
 
-  return getWasmSection(Section, Type, Flags, GroupSym, UniqueID, BeginSymName);
+  return getWasmSection(Section, Type, GroupSym, UniqueID, BeginSymName);
 }
 
 MCSectionWasm *MCContext::getWasmSection(const Twine &Section, unsigned Type,
-                                         unsigned Flags,
                                          const MCSymbolWasm *GroupSym,
                                          unsigned UniqueID,
                                          const char *BeginSymName) {
@@ -555,7 +519,7 @@ MCSectionWasm *MCContext::getWasmSection
     Begin = createTempSymbol(BeginSymName, false);
 
   MCSectionWasm *Result = new (WasmAllocator.Allocate())
-      MCSectionWasm(CachedName, Type, Flags, Kind, GroupSym, UniqueID, Begin);
+      MCSectionWasm(CachedName, Type, Kind, GroupSym, UniqueID, Begin);
   Entry.second = Result;
   return Result;
 }

Modified: llvm/trunk/lib/MC/MCObjectFileInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=313058&r1=313057&r2=313058&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectFileInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectFileInfo.cpp Tue Sep 12 11:31:24 2017
@@ -820,24 +820,24 @@ void MCObjectFileInfo::initCOFFMCObjectF
 
 void MCObjectFileInfo::initWasmMCObjectFileInfo(const Triple &T) {
   // TODO: Set the section types and flags.
-  TextSection = Ctx->getWasmSection(".text", 0, 0);
-  DataSection = Ctx->getWasmSection(".data", 0, 0);
+  TextSection = Ctx->getWasmSection(".text", 0);
+  DataSection = Ctx->getWasmSection(".data", 0);
 
   // TODO: Set the section types and flags.
-  DwarfLineSection = Ctx->getWasmSection(".debug_line", 0, 0);
-  DwarfStrSection = Ctx->getWasmSection(".debug_str", 0, 0);
-  DwarfLocSection = Ctx->getWasmSection(".debug_loc", 0, 0);
-  DwarfAbbrevSection = Ctx->getWasmSection(".debug_abbrev", 0, 0, "section_abbrev");
-  DwarfARangesSection = Ctx->getWasmSection(".debug_aranges", 0, 0);
-  DwarfRangesSection = Ctx->getWasmSection(".debug_ranges", 0, 0, "debug_range");
-  DwarfMacinfoSection = Ctx->getWasmSection(".debug_macinfo", 0, 0, "debug_macinfo");
-  DwarfAddrSection = Ctx->getWasmSection(".debug_addr", 0, 0);
-  DwarfCUIndexSection = Ctx->getWasmSection(".debug_cu_index", 0, 0);
-  DwarfTUIndexSection = Ctx->getWasmSection(".debug_tu_index", 0, 0);
-  DwarfInfoSection = Ctx->getWasmSection(".debug_info", 0, 0, "section_info");
-  DwarfFrameSection = Ctx->getWasmSection(".debug_frame", 0, 0);
-  DwarfPubNamesSection = Ctx->getWasmSection(".debug_pubnames", 0, 0);
-  DwarfPubTypesSection = Ctx->getWasmSection(".debug_pubtypes", 0, 0);
+  DwarfLineSection = Ctx->getWasmSection(".debug_line", 0);
+  DwarfStrSection = Ctx->getWasmSection(".debug_str", 0);
+  DwarfLocSection = Ctx->getWasmSection(".debug_loc", 0);
+  DwarfAbbrevSection = Ctx->getWasmSection(".debug_abbrev", 0, "section_abbrev");
+  DwarfARangesSection = Ctx->getWasmSection(".debug_aranges", 0);
+  DwarfRangesSection = Ctx->getWasmSection(".debug_ranges", 0, "debug_range");
+  DwarfMacinfoSection = Ctx->getWasmSection(".debug_macinfo", 0, "debug_macinfo");
+  DwarfAddrSection = Ctx->getWasmSection(".debug_addr", 0);
+  DwarfCUIndexSection = Ctx->getWasmSection(".debug_cu_index", 0);
+  DwarfTUIndexSection = Ctx->getWasmSection(".debug_tu_index", 0);
+  DwarfInfoSection = Ctx->getWasmSection(".debug_info", 0, "section_info");
+  DwarfFrameSection = Ctx->getWasmSection(".debug_frame", 0);
+  DwarfPubNamesSection = Ctx->getWasmSection(".debug_pubnames", 0);
+  DwarfPubTypesSection = Ctx->getWasmSection(".debug_pubtypes", 0);
 
   // TODO: Define more sections.
 }




More information about the llvm-commits mailing list