diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h index 57ba40f7ac26f..e97c890ce9135 100644 --- a/llvm/include/llvm/MC/MCContext.h +++ b/llvm/include/llvm/MC/MCContext.h @@ -527,13 +527,6 @@ class MCContext { /// \name Section Management /// @{ - enum : unsigned { - /// Pass this value as the UniqueID during section creation to get the - /// generic section with the given name and characteristics. The usual - /// sections such as .text use this ID. - GenericSectionID = ~0U - }; - /// Return the MCSection for the specified mach-o section. This requires /// the operands to be valid. MCSectionMachO *getMachOSection(StringRef Segment, StringRef Section, @@ -611,7 +604,7 @@ class MCContext { MCSectionCOFF *getCOFFSection(StringRef Section, unsigned Characteristics, StringRef COMDATSymName, int Selection, - unsigned UniqueID = GenericSectionID); + unsigned UniqueID = MCSection::NonUniqueID); MCSectionCOFF *getCOFFSection(StringRef Section, unsigned Characteristics); @@ -621,7 +614,7 @@ class MCContext { /// as Sec and the function symbol as KeySym. MCSectionCOFF * getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym, - unsigned UniqueID = GenericSectionID); + unsigned UniqueID = MCSection::NonUniqueID); MCSectionSPIRV *getSPIRVSection(); diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 6cbc4b9776a1b..9f44f8b1c0f56 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -758,7 +758,7 @@ calcUniqueIDUpdateFlagsAndSize(const GlobalObject *GO, StringRef SectionName, if (!SupportsUnique) { Flags &= ~ELF::SHF_MERGE; EntrySize = 0; - return MCContext::GenericSectionID; + return MCSection::NonUniqueID; } const bool SymbolMergeable = Flags & ELF::SHF_MERGE; @@ -770,7 +770,7 @@ calcUniqueIDUpdateFlagsAndSize(const GlobalObject *GO, StringRef SectionName, if (TM.getSeparateNamedSections()) return NextUniqueID++; else - return MCContext::GenericSectionID; + return MCSection::NonUniqueID; } // Symbols must be placed into sections with compatible entry sizes. Generate @@ -778,8 +778,8 @@ calcUniqueIDUpdateFlagsAndSize(const GlobalObject *GO, StringRef SectionName, // sections. const auto PreviousID = Ctx.getELFUniqueIDForEntsize(SectionName, Flags, EntrySize); - if (PreviousID && (!TM.getSeparateNamedSections() || - *PreviousID == MCContext::GenericSectionID)) + if (PreviousID && + (!TM.getSeparateNamedSections() || *PreviousID == MCSection::NonUniqueID)) return *PreviousID; // If the user has specified the same section name as would be created @@ -791,7 +791,7 @@ calcUniqueIDUpdateFlagsAndSize(const GlobalObject *GO, StringRef SectionName, if (SymbolMergeable && Ctx.isELFImplicitMergeableSectionNamePrefix(SectionName) && SectionName.starts_with(ImplicitSectionNameStem)) - return MCContext::GenericSectionID; + return MCSection::NonUniqueID; // We have seen this section name before, but with different flags or entity // size. Create a new unique ID. @@ -903,7 +903,7 @@ static MCSectionELF *selectELFSectionForGlobal( unsigned EntrySize = getEntrySizeForKind(Kind); bool UniqueSectionName = false; - unsigned UniqueID = MCContext::GenericSectionID; + unsigned UniqueID = MCSection::NonUniqueID; if (EmitUniqueSection) { if (TM.getUniqueSectionNames()) { UniqueSectionName = true; @@ -1073,7 +1073,7 @@ MCSection *TargetLoweringObjectFileELF::getSectionForMachineBasicBlock( const Function &F, const MachineBasicBlock &MBB, const TargetMachine &TM) const { assert(MBB.isBeginSection() && "Basic block does not start a section!"); - unsigned UniqueID = MCContext::GenericSectionID; + unsigned UniqueID = MCSection::NonUniqueID; // For cold sections use the .text.split. prefix along with the parent // function name. All cold blocks for the same function go to the same @@ -1774,7 +1774,7 @@ MCSection *TargetLoweringObjectFileCOFF::SelectSectionForGlobal( else ComdatGV = GO; - unsigned UniqueID = MCContext::GenericSectionID; + unsigned UniqueID = MCSection::NonUniqueID; if (EmitUniquedSection) UniqueID = NextUniqueID++; @@ -2220,8 +2220,8 @@ MCSection *TargetLoweringObjectFileWasm::getExplicitSectionGlobal( } unsigned Flags = getWasmSectionFlags(Kind, Used.count(GO)); - MCSectionWasm *Section = getContext().getWasmSection( - Name, Kind, Flags, Group, MCContext::GenericSectionID); + MCSectionWasm *Section = getContext().getWasmSection(Name, Kind, Flags, Group, + MCSection::NonUniqueID); return Section; } @@ -2249,7 +2249,7 @@ selectWasmSectionForGlobal(MCContext &Ctx, const GlobalObject *GO, Name.push_back('.'); TM.getNameWithPrefix(Name, GO, Mang, true); } - unsigned UniqueID = MCContext::GenericSectionID; + unsigned UniqueID = MCSection::NonUniqueID; if (EmitUniqueSection && !UniqueSectionNames) { UniqueID = *NextUniqueID; (*NextUniqueID)++; diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 335febde3687c..09d4b518cc1c5 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -636,7 +636,7 @@ void MCContext::recordELFMergeableSectionInfo(StringRef SectionName, unsigned Flags, unsigned UniqueID, unsigned EntrySize) { bool IsMergeable = Flags & ELF::SHF_MERGE; - if (UniqueID == GenericSectionID) { + if (UniqueID == MCSection::NonUniqueID) { ELFSeenGenericMergeableSections.insert(SectionName); // Minor performance optimization: avoid hash map lookup in // isELFGenericMergeableSection, which will return true for SectionName. @@ -727,14 +727,15 @@ MCSectionCOFF *MCContext::getCOFFSection(StringRef Section, MCSectionCOFF *MCContext::getCOFFSection(StringRef Section, unsigned Characteristics) { - return getCOFFSection(Section, Characteristics, "", 0, GenericSectionID); + return getCOFFSection(Section, Characteristics, "", 0, + MCSection::NonUniqueID); } MCSectionCOFF *MCContext::getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym, unsigned UniqueID) { // Return the normal section if we don't have to be associative or unique. - if (!KeySym && UniqueID == GenericSectionID) + if (!KeySym && UniqueID == MCSection::NonUniqueID) return Sec; // If we have a key symbol, make an associative section with the same name and diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index 150e38a94db6a..ab7552ca01061 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -1066,7 +1066,7 @@ MCSection *MCObjectFileInfo::getDwarfComdatSection(const char *Name, utostr(Hash), /*IsComdat=*/true); case Triple::Wasm: return Ctx->getWasmSection(Name, SectionKind::getMetadata(), 0, - utostr(Hash), MCContext::GenericSectionID); + utostr(Hash), MCSection::NonUniqueID); case Triple::MachO: case Triple::COFF: case Triple::GOFF: diff --git a/llvm/lib/MC/MCParser/WasmAsmParser.cpp b/llvm/lib/MC/MCParser/WasmAsmParser.cpp index d8ab30f296c3c..a3c40d6194607 100644 --- a/llvm/lib/MC/MCParser/WasmAsmParser.cpp +++ b/llvm/lib/MC/MCParser/WasmAsmParser.cpp @@ -193,7 +193,7 @@ class WasmAsmParser : public MCAsmParserExtension { // TODO: Parse UniqueID MCSectionWasm *WS = getContext().getWasmSection( - Name, *Kind, Flags, GroupName, MCContext::GenericSectionID); + Name, *Kind, Flags, GroupName, MCSection::NonUniqueID); if (WS->getSegmentFlags() != Flags) Parser->Error(loc, "changed section flags for " + Name + diff --git a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp index f693ef3dbf962..2a4e2c897b18d 100644 --- a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp +++ b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp @@ -1246,7 +1246,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser { if (Group) WasmSym->setComdat(true); auto *WS = getContext().getWasmSection(SecName, SectionKind::getText(), 0, - Group, MCContext::GenericSectionID); + Group, MCSection::NonUniqueID); getStreamer().switchSection(WS); // Also generate DWARF for this section if requested. if (getContext().getGenDwarfForAssembly())