[llvm] [MC] Remove SectionKind from MCSection (PR #96067)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 19 06:00:30 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-arm
@llvm/pr-subscribers-backend-nvptx
Author: None (aengelke)
<details>
<summary>Changes</summary>
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.
---
@<!-- -->compnerd -- you mentioned "subsequent changes for handling target
specific behaviour", did this ever materialize? At least, no tests fail when removing this.
This also has some cleanup. I left two separate commits in this PR so that the second can be easily removed if this is seen as too invasive.
(If there is actually a need for the string switch, it should be moved to the point where it is actually required. In most cases, the section kind is well known when the section is created and the section kind should not be re-discovered solely based on the name.)
---
Patch is 66.03 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/96067.diff
27 Files Affected:
- (modified) llvm/include/llvm/MC/MCContext.h (+2-5)
- (modified) llvm/include/llvm/MC/MCSection.h (+4-3)
- (modified) llvm/include/llvm/MC/MCSectionCOFF.h (+6-4)
- (modified) llvm/include/llvm/MC/MCSectionDXContainer.h (+1-1)
- (modified) llvm/include/llvm/MC/MCSectionELF.h (+5-4)
- (modified) llvm/include/llvm/MC/MCSectionGOFF.h (+2-1)
- (modified) llvm/include/llvm/MC/MCSectionSPIRV.h (+2-2)
- (modified) llvm/include/llvm/MC/MCSectionWasm.h (+9-6)
- (modified) llvm/include/llvm/MC/MCSectionXCOFF.h (+6-4)
- (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+4-5)
- (modified) llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (+1-2)
- (modified) llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (+16-24)
- (modified) llvm/lib/MC/MCContext.cpp (+12-59)
- (modified) llvm/lib/MC/MCObjectFileInfo.cpp (+89-114)
- (modified) llvm/lib/MC/MCParser/COFFAsmParser.cpp (+14-34)
- (modified) llvm/lib/MC/MCParser/COFFMasmParser.cpp (+22-29)
- (modified) llvm/lib/MC/MCSection.cpp (+3-3)
- (modified) llvm/lib/MC/MCSectionCOFF.cpp (+1-1)
- (modified) llvm/lib/MC/MCSectionMachO.cpp (+1-1)
- (modified) llvm/lib/MC/MCStreamer.cpp (+4-4)
- (modified) llvm/lib/MC/WasmObjectWriter.cpp (+7-7)
- (modified) llvm/lib/MC/WinCOFFObjectWriter.cpp (+2-4)
- (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp (+2-1)
- (modified) llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp (+1-2)
- (modified) llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp (+2-2)
- (modified) llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp (+4-4)
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp (+2-2)
``````````diff
diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h
index 7c70a29b243de..3fe4c2885f6b5 100644
--- a/llvm/include/llvm/MC/MCContext.h
+++ b/llvm/include/llvm/MC/MCContext.h
@@ -357,8 +357,7 @@ class MCContext {
unsigned Instance);
MCSectionELF *createELFSectionImpl(StringRef Section, unsigned Type,
- unsigned Flags, SectionKind K,
- unsigned EntrySize,
+ unsigned Flags, unsigned EntrySize,
const MCSymbolELF *Group, bool IsComdat,
unsigned UniqueID,
const MCSymbolELF *LinkedToSym);
@@ -602,13 +601,11 @@ class MCContext {
MCSection *Parent, const MCExpr *SubsectionId);
MCSectionCOFF *getCOFFSection(StringRef Section, unsigned Characteristics,
- SectionKind Kind, StringRef COMDATSymName,
- int Selection,
+ StringRef COMDATSymName, int Selection,
unsigned UniqueID = GenericSectionID,
const char *BeginSymName = nullptr);
MCSectionCOFF *getCOFFSection(StringRef Section, unsigned Characteristics,
- SectionKind Kind,
const char *BeginSymName = nullptr);
/// Gets or creates a section equivalent to Sec that is associated with the
diff --git a/llvm/include/llvm/MC/MCSection.h b/llvm/include/llvm/MC/MCSection.h
index c7c0de60a411e..9b3df81324226 100644
--- a/llvm/include/llvm/MC/MCSection.h
+++ b/llvm/include/llvm/MC/MCSection.h
@@ -104,6 +104,8 @@ class MCSection {
bool IsRegistered : 1;
+ bool IsText : 1;
+
MCDummyFragment DummyFragment;
// Mapping from subsection number to fragment list. At layout time, the
@@ -124,9 +126,8 @@ class MCSection {
// TODO Make Name private when possible.
StringRef Name;
SectionVariant Variant;
- SectionKind Kind;
- MCSection(SectionVariant V, StringRef Name, SectionKind K, MCSymbol *Begin);
+ MCSection(SectionVariant V, StringRef Name, bool IsText, MCSymbol *Begin);
~MCSection();
public:
@@ -134,7 +135,7 @@ class MCSection {
MCSection &operator=(const MCSection &) = delete;
StringRef getName() const { return Name; }
- SectionKind getKind() const { return Kind; }
+ bool isText() const { return IsText; }
SectionVariant getVariant() const { return Variant; }
diff --git a/llvm/include/llvm/MC/MCSectionCOFF.h b/llvm/include/llvm/MC/MCSectionCOFF.h
index 2faf84f0372cb..c99e7d405d001 100644
--- a/llvm/include/llvm/MC/MCSectionCOFF.h
+++ b/llvm/include/llvm/MC/MCSectionCOFF.h
@@ -14,6 +14,7 @@
#define LLVM_MC_MCSECTIONCOFF_H
#include "llvm/ADT/StringRef.h"
+#include "llvm/BinaryFormat/COFF.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/SectionKind.h"
#include <cassert>
@@ -50,10 +51,11 @@ class MCSectionCOFF final : public MCSection {
friend class MCContext;
// The storage of Name is owned by MCContext's COFFUniquingMap.
MCSectionCOFF(StringRef Name, unsigned Characteristics,
- MCSymbol *COMDATSymbol, int Selection, SectionKind K,
- MCSymbol *Begin)
- : MCSection(SV_COFF, Name, K, Begin), Characteristics(Characteristics),
- COMDATSymbol(COMDATSymbol), Selection(Selection) {
+ MCSymbol *COMDATSymbol, int Selection, MCSymbol *Begin)
+ : MCSection(SV_COFF, Name, Characteristics & COFF::IMAGE_SCN_CNT_CODE,
+ Begin),
+ Characteristics(Characteristics), COMDATSymbol(COMDATSymbol),
+ Selection(Selection) {
assert((Characteristics & 0x00F00000) == 0 &&
"alignment must not be set upon section creation");
}
diff --git a/llvm/include/llvm/MC/MCSectionDXContainer.h b/llvm/include/llvm/MC/MCSectionDXContainer.h
index 014684a935295..4ef2f29d7e67d 100644
--- a/llvm/include/llvm/MC/MCSectionDXContainer.h
+++ b/llvm/include/llvm/MC/MCSectionDXContainer.h
@@ -24,7 +24,7 @@ class MCSectionDXContainer final : public MCSection {
friend class MCContext;
MCSectionDXContainer(StringRef Name, SectionKind K, MCSymbol *Begin)
- : MCSection(SV_DXContainer, Name, K, Begin) {}
+ : MCSection(SV_DXContainer, Name, K.isText(), Begin) {}
public:
void printSwitchToSection(const MCAsmInfo &, const Triple &, raw_ostream &,
diff --git a/llvm/include/llvm/MC/MCSectionELF.h b/llvm/include/llvm/MC/MCSectionELF.h
index 3b5239394493c..ff9240ff4e32d 100644
--- a/llvm/include/llvm/MC/MCSectionELF.h
+++ b/llvm/include/llvm/MC/MCSectionELF.h
@@ -15,6 +15,7 @@
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/BinaryFormat/ELF.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSymbolELF.h"
#include "llvm/MC/SectionKind.h"
@@ -49,13 +50,13 @@ class MCSectionELF final : public MCSection {
friend class MCContext;
// The storage of Name is owned by MCContext's ELFUniquingMap.
- MCSectionELF(StringRef Name, unsigned type, unsigned flags, SectionKind K,
+ MCSectionELF(StringRef Name, unsigned type, unsigned flags,
unsigned entrySize, const MCSymbolELF *group, bool IsComdat,
unsigned UniqueID, MCSymbol *Begin,
const MCSymbolELF *LinkedToSym)
- : MCSection(SV_ELF, Name, K, Begin), Type(type), Flags(flags),
- UniqueID(UniqueID), EntrySize(entrySize), Group(group, IsComdat),
- LinkedToSym(LinkedToSym) {
+ : MCSection(SV_ELF, Name, flags & ELF::SHF_EXECINSTR, Begin), Type(type),
+ Flags(flags), UniqueID(UniqueID), EntrySize(entrySize),
+ Group(group, IsComdat), LinkedToSym(LinkedToSym) {
if (Group.getPointer())
Group.getPointer()->setIsSignature();
}
diff --git a/llvm/include/llvm/MC/MCSectionGOFF.h b/llvm/include/llvm/MC/MCSectionGOFF.h
index d866329461cea..1cc13757abb8d 100644
--- a/llvm/include/llvm/MC/MCSectionGOFF.h
+++ b/llvm/include/llvm/MC/MCSectionGOFF.h
@@ -30,7 +30,8 @@ class MCSectionGOFF final : public MCSection {
friend class MCContext;
MCSectionGOFF(StringRef Name, SectionKind K, MCSection *P, const MCExpr *Sub)
- : MCSection(SV_GOFF, Name, K, nullptr), Parent(P), SubsectionId(Sub) {}
+ : MCSection(SV_GOFF, Name, K.isText(), nullptr), Parent(P),
+ SubsectionId(Sub) {}
public:
void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
diff --git a/llvm/include/llvm/MC/MCSectionSPIRV.h b/llvm/include/llvm/MC/MCSectionSPIRV.h
index 6534599d2091c..0b2b15b4e3dcd 100644
--- a/llvm/include/llvm/MC/MCSectionSPIRV.h
+++ b/llvm/include/llvm/MC/MCSectionSPIRV.h
@@ -23,8 +23,8 @@ class MCSymbol;
class MCSectionSPIRV final : public MCSection {
friend class MCContext;
- MCSectionSPIRV(SectionKind K, MCSymbol *Begin)
- : MCSection(SV_SPIRV, "", K, Begin) {}
+ MCSectionSPIRV()
+ : MCSection(SV_SPIRV, "", /*IsText=*/true, /*Begin=*/nullptr) {}
// TODO: Add StringRef Name to MCSectionSPIRV.
public:
diff --git a/llvm/include/llvm/MC/MCSectionWasm.h b/llvm/include/llvm/MC/MCSectionWasm.h
index 23eba093a3b21..a94397c37060c 100644
--- a/llvm/include/llvm/MC/MCSectionWasm.h
+++ b/llvm/include/llvm/MC/MCSectionWasm.h
@@ -40,6 +40,10 @@ class MCSectionWasm final : public MCSection {
// For data sections, whether to use a passive segment
bool IsPassive = false;
+ bool IsWasmData;
+
+ bool IsMetadata;
+
// For data sections, bitfield of WasmSegmentFlag
unsigned SegmentFlags;
@@ -47,8 +51,9 @@ class MCSectionWasm final : public MCSection {
friend class MCContext;
MCSectionWasm(StringRef Name, SectionKind K, unsigned SegmentFlags,
const MCSymbolWasm *Group, unsigned UniqueID, MCSymbol *Begin)
- : MCSection(SV_Wasm, Name, K, Begin), UniqueID(UniqueID), Group(Group),
- SegmentFlags(SegmentFlags) {}
+ : MCSection(SV_Wasm, Name, K.isText(), Begin), UniqueID(UniqueID),
+ Group(Group), IsWasmData(K.isReadOnly() || K.isWriteable()),
+ IsMetadata(K.isMetadata()), SegmentFlags(SegmentFlags) {}
public:
/// Decides whether a '.section' directive should be printed before the
@@ -64,10 +69,8 @@ class MCSectionWasm final : public MCSection {
bool useCodeAlign() const override;
bool isVirtualSection() const override;
- bool isWasmData() const {
- return Kind.isGlobalWriteableData() || Kind.isReadOnly() ||
- Kind.isThreadLocal();
- }
+ bool isWasmData() const { return IsWasmData; }
+ bool isMetadata() const { return IsMetadata; }
bool isUnique() const { return UniqueID != ~0U; }
unsigned getUniqueID() const { return UniqueID; }
diff --git a/llvm/include/llvm/MC/MCSectionXCOFF.h b/llvm/include/llvm/MC/MCSectionXCOFF.h
index 7b7a58f26bca3..11bcfc8e63a6b 100644
--- a/llvm/include/llvm/MC/MCSectionXCOFF.h
+++ b/llvm/include/llvm/MC/MCSectionXCOFF.h
@@ -37,6 +37,7 @@ class MCSectionXCOFF final : public MCSection {
StringRef SymbolTableName;
std::optional<XCOFF::DwarfSectionSubtypeFlags> DwarfSubtypeFlags;
bool MultiSymbolsAllowed;
+ SectionKind Kind;
static constexpr unsigned DefaultAlignVal = 4;
static constexpr unsigned DefaultTextAlignVal = 32;
@@ -44,10 +45,10 @@ class MCSectionXCOFF final : public MCSection {
XCOFF::SymbolType ST, SectionKind K, MCSymbolXCOFF *QualName,
MCSymbol *Begin, StringRef SymbolTableName,
bool MultiSymbolsAllowed)
- : MCSection(SV_XCOFF, Name, K, Begin),
+ : MCSection(SV_XCOFF, Name, K.isText(), Begin),
CsectProp(XCOFF::CsectProperties(SMC, ST)), QualName(QualName),
SymbolTableName(SymbolTableName), DwarfSubtypeFlags(std::nullopt),
- MultiSymbolsAllowed(MultiSymbolsAllowed) {
+ MultiSymbolsAllowed(MultiSymbolsAllowed), Kind(K) {
assert(
(ST == XCOFF::XTY_SD || ST == XCOFF::XTY_CM || ST == XCOFF::XTY_ER) &&
"Invalid or unhandled type for csect.");
@@ -72,9 +73,9 @@ class MCSectionXCOFF final : public MCSection {
XCOFF::DwarfSectionSubtypeFlags DwarfSubtypeFlags,
MCSymbol *Begin, StringRef SymbolTableName,
bool MultiSymbolsAllowed)
- : MCSection(SV_XCOFF, Name, K, Begin), QualName(QualName),
+ : MCSection(SV_XCOFF, Name, K.isText(), Begin), QualName(QualName),
SymbolTableName(SymbolTableName), DwarfSubtypeFlags(DwarfSubtypeFlags),
- MultiSymbolsAllowed(MultiSymbolsAllowed) {
+ MultiSymbolsAllowed(MultiSymbolsAllowed), Kind(K) {
assert(QualName != nullptr && "QualName is needed.");
// FIXME: use a more meaningful name for non csect sections.
@@ -125,6 +126,7 @@ class MCSectionXCOFF final : public MCSection {
std::optional<XCOFF::CsectProperties> getCsectProp() const {
return CsectProp;
}
+ SectionKind getKind() const { return Kind; }
};
} // end namespace llvm
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 3580d484b7ddd..766fb3633b281 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2415,8 +2415,7 @@ bool AsmPrinter::doFinalization(Module &M) {
SectionName,
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ |
COFF::IMAGE_SCN_LNK_COMDAT,
- SectionKind::getReadOnly(), Stub.first->getName(),
- COFF::IMAGE_COMDAT_SELECT_ANY));
+ Stub.first->getName(), COFF::IMAGE_COMDAT_SELECT_ANY));
emitAlignment(Align(DL.getPointerSize()));
OutStreamer->emitSymbolAttribute(Stub.first, MCSA_Global);
OutStreamer->emitLabel(Stub.first);
@@ -2898,8 +2897,8 @@ bool AsmPrinter::emitSpecialLLVMGlobal(const GlobalVariable *GV) {
// For ARM64EC, print the table that maps between symbols and the
// corresponding thunks to translate between x64 and AArch64 code.
// This table is generated by AArch64Arm64ECCallLowering.
- OutStreamer->switchSection(OutContext.getCOFFSection(
- ".hybmp$x", COFF::IMAGE_SCN_LNK_INFO, SectionKind::getMetadata()));
+ OutStreamer->switchSection(
+ OutContext.getCOFFSection(".hybmp$x", COFF::IMAGE_SCN_LNK_INFO));
auto *Arr = cast<ConstantArray>(GV->getInitializer());
for (auto &U : Arr->operands()) {
auto *C = cast<Constant>(U);
@@ -3158,7 +3157,7 @@ void AsmPrinter::emitAlignment(Align Alignment, const GlobalObject *GV,
if (Alignment == Align(1))
return; // 1-byte aligned: no need to emit alignment.
- if (getCurrentSection()->getKind().isText()) {
+ if (getCurrentSection()->isText()) {
const MCSubtargetInfo *STI = nullptr;
if (this->MF)
STI = &getSubtargetInfo();
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 7d3ea9352bd6c..dd7d9e5deac2e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2998,8 +2998,7 @@ void DwarfDebug::emitDebugARanges() {
if (SCU.Sym->isInSection()) {
// Make a note of this symbol and it's section.
MCSection *Section = &SCU.Sym->getSection();
- if (!Section->getKind().isMetadata())
- SectionMap[Section].push_back(SCU);
+ SectionMap[Section].push_back(SCU);
} else {
// Some symbols (e.g. common/bss on mach-o) can have no section but still
// appear in the output. This sucks as we rely on sections to build
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 0fc915d89f6c0..b2c1750131a2f 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);
}
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index f12a3bc0e56f5..432ff5e7a7c28 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -479,7 +479,7 @@ MCSectionMachO *MCContext::getMachOSection(StringRef Segment, StringRef Section,
}
MCSectionELF *MCContext::createELFSectionImpl(StringRef Section, unsigned Type,
- unsigned Flags, SectionKind K,
+ unsigned Flags,
unsigned EntrySize,
const MCSymbolELF *Group,
bool Comdat, unsigned UniqueID,
@@ -502,9 +502,8 @@ MCSectionELF *MCContext::createELFSectionImpl(StringRef Section, unsigned Type,
R->setBinding(ELF::STB_LOCAL);
R->setType(ELF::STT_SECTION);
- auto *Ret = new (ELFAllocator.Allocate())
- MCSectionELF(Section, Type, Flags, K, EntrySize, Group, Comdat, UniqueID,
- R, LinkedToSym);
+ auto *Ret = new (ELFAllocator.Allocate()) MCSectionELF(
+ Section, Type, Flags, EntrySize, Group, Comdat, UniqueID, R, LinkedToSym);
auto *F = allocInitialFragment(*Ret);
R->setFragment(F);
@@ -520,8 +519,8 @@ MCContext::createELFRelSection(...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/96067
More information about the llvm-commits
mailing list