diff options
author | aengelke <engelke@in.tum.de> | 2024-06-20 10:52:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-20 10:52:49 +0200 |
commit | 46beeaa3940ef8380ee99b9f666cd27b884f63e4 (patch) | |
tree | 3109f60e7bc264ec8c2d62ca829c14e6ed5b6870 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | |
parent | acf675b63f9426e61aac2155e29280f7d21f9421 (diff) | |
download | llvm-46beeaa3940ef8380ee99b9f666cd27b884f63e4.zip llvm-46beeaa3940ef8380ee99b9f666cd27b884f63e4.tar.gz llvm-46beeaa3940ef8380ee99b9f666cd27b884f63e4.tar.bz2 |
[MC] Remove SectionKind from MCSection (#96067)
There are only three actual uses of the section kind in MCSection:
isText(), XCOFF, and WebAssembly. Store isText() in the MCSection, and
store other info in the actual section variants where required.
ELF and COFF flags also encode all relevant information, so for these
two section variants, remove the SectionKind parameter entirely.
This allows to remove the string switch (which is unnecessary and
inaccurate) from createELFSectionImpl. This was introduced in
[D133456](https://reviews.llvm.org/D133456), but apparently, it was
never hit for non-writable sections anyway and the resulting kind was
never used.
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 0fc915d..b2c1750 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -1696,7 +1696,7 @@ MCSection *TargetLoweringObjectFileCOFF::getExplicitSectionGlobal( } } - return getContext().getCOFFSection(Name, Characteristics, Kind, COMDATSymName, + return getContext().getCOFFSection(Name, Characteristics, COMDATSymName, Selection); } @@ -1755,12 +1755,12 @@ MCSection *TargetLoweringObjectFileCOFF::SelectSectionForGlobal( if (getContext().getTargetTriple().isWindowsGNUEnvironment()) raw_svector_ostream(Name) << '$' << ComdatGV->getName(); - return getContext().getCOFFSection(Name, Characteristics, Kind, - COMDATSymName, Selection, UniqueID); + return getContext().getCOFFSection(Name, Characteristics, COMDATSymName, + Selection, UniqueID); } else { SmallString<256> TmpData; getMangler().getNameWithPrefix(TmpData, GO, /*CannotUsePrivateLabel=*/true); - return getContext().getCOFFSection(Name, Characteristics, Kind, TmpData, + return getContext().getCOFFSection(Name, Characteristics, TmpData, Selection, UniqueID); } } @@ -1817,9 +1817,9 @@ MCSection *TargetLoweringObjectFileCOFF::getSectionForJumpTable( Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT; unsigned UniqueID = NextUniqueID++; - return getContext().getCOFFSection( - SecName, Characteristics, Kind, COMDATSymName, - COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE, UniqueID); + return getContext().getCOFFSection(SecName, Characteristics, COMDATSymName, + COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE, + UniqueID); } bool TargetLoweringObjectFileCOFF::shouldPutJumpTableInFunctionSection( @@ -1846,10 +1846,8 @@ void TargetLoweringObjectFileCOFF::emitModuleMetadata(MCStreamer &Streamer, GetObjCImageInfo(M, Version, Flags, Section); if (!Section.empty()) { auto &C = getContext(); - auto *S = C.getCOFFSection(Section, - COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | - COFF::IMAGE_SCN_MEM_READ, - SectionKind::getReadOnly()); + auto *S = C.getCOFFSection(Section, COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | + COFF::IMAGE_SCN_MEM_READ); Streamer.switchSection(S); Streamer.emitLabel(C.getOrCreateSymbol(StringRef("OBJC_IMAGE_INFO"))); Streamer.emitInt32(Version); @@ -1929,21 +1927,17 @@ void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx, if (T.isWindowsMSVCEnvironment() || T.isWindowsItaniumEnvironment()) { StaticCtorSection = Ctx.getCOFFSection(".CRT$XCU", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | - COFF::IMAGE_SCN_MEM_READ, - SectionKind::getReadOnly()); + COFF::IMAGE_SCN_MEM_READ); StaticDtorSection = Ctx.getCOFFSection(".CRT$XTX", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | - COFF::IMAGE_SCN_MEM_READ, - SectionKind::getReadOnly()); + COFF::IMAGE_SCN_MEM_READ); } else { StaticCtorSection = Ctx.getCOFFSection( ".ctors", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | - COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE, - SectionKind::getData()); + COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE); StaticDtorSection = Ctx.getCOFFSection( ".dtors", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | - COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE, - SectionKind::getData()); + COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE); } } @@ -1981,8 +1975,7 @@ static MCSectionCOFF *getCOFFStaticStructorSection(MCContext &Ctx, if (AddPrioritySuffix) OS << format("%05u", Priority); MCSectionCOFF *Sec = Ctx.getCOFFSection( - Name, COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ, - SectionKind::getReadOnly()); + Name, COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ); return Ctx.getAssociativeCOFFSection(Sec, KeySym, 0); } @@ -1993,8 +1986,7 @@ static MCSectionCOFF *getCOFFStaticStructorSection(MCContext &Ctx, return Ctx.getAssociativeCOFFSection( Ctx.getCOFFSection(Name, COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ | - COFF::IMAGE_SCN_MEM_WRITE, - SectionKind::getData()), + COFF::IMAGE_SCN_MEM_WRITE), KeySym, 0); } @@ -2112,7 +2104,7 @@ MCSection *TargetLoweringObjectFileCOFF::getSectionForConstant( } if (!COMDATSymName.empty()) - return getContext().getCOFFSection(".rdata", Characteristics, Kind, + return getContext().getCOFFSection(".rdata", Characteristics, COMDATSymName, COFF::IMAGE_COMDAT_SELECT_ANY); } |