mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 12:56:35 +00:00
[MC] Replace MCContext::GenericSectionID with MCSection::NonUniqueID (#126202)
They have same semantics. NonUniqueID is more friendly for isUnique implementation in MCSectionELF. History: 97837b7 added support for unique IDs in sections and added GenericSectionID. Later, 1dc16c7 added NonUniqueID.
This commit is contained in:
parent
d222488007
commit
ec28e9b757
@ -527,13 +527,6 @@ public:
|
||||
/// \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 @@ public:
|
||||
|
||||
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 @@ public:
|
||||
/// as Sec and the function symbol as KeySym.
|
||||
MCSectionCOFF *
|
||||
getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym,
|
||||
unsigned UniqueID = GenericSectionID);
|
||||
unsigned UniqueID = MCSection::NonUniqueID);
|
||||
|
||||
MCSectionSPIRV *getSPIRVSection();
|
||||
|
||||
|
@ -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)++;
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -193,7 +193,7 @@ public:
|
||||
|
||||
// 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 +
|
||||
|
@ -1246,7 +1246,7 @@ public:
|
||||
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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user