Skip to content

Commit 1dc16c7

Browse files
committed
[MC] Add MCSection::NonUniqueID and delete one MCContext::getELFSection overload
1 parent 0fbe221 commit 1dc16c7

File tree

6 files changed

+11
-14
lines changed

6 files changed

+11
-14
lines changed

llvm/include/llvm/MC/MCContext.h

+2-8
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,8 @@ namespace llvm {
435435
MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
436436
unsigned Flags, unsigned EntrySize,
437437
const Twine &Group) {
438-
return getELFSection(Section, Type, Flags, EntrySize, Group, ~0);
439-
}
440-
441-
MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
442-
unsigned Flags, unsigned EntrySize,
443-
const Twine &Group, unsigned UniqueID) {
444-
return getELFSection(Section, Type, Flags, EntrySize, Group, UniqueID,
445-
nullptr);
438+
return getELFSection(Section, Type, Flags, EntrySize, Group,
439+
MCSection::NonUniqueID, nullptr);
446440
}
447441

448442
MCSectionELF *getELFSection(const Twine &Section, unsigned Type,

llvm/include/llvm/MC/MCSection.h

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ template <> struct ilist_alloc_traits<MCFragment> {
3838
/// current translation unit. The MCContext class uniques and creates these.
3939
class MCSection {
4040
public:
41+
static constexpr unsigned NonUniqueID = ~0U;
42+
4143
enum SectionVariant { SV_COFF = 0, SV_ELF, SV_MachO, SV_Wasm, SV_XCOFF };
4244

4345
/// Express the state of bundle locked groups while emitting code.

llvm/include/llvm/MC/MCSectionELF.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class MCSectionELF final : public MCSection {
8181
bool UseCodeAlign() const override;
8282
bool isVirtualSection() const override;
8383

84-
bool isUnique() const { return UniqueID != ~0U; }
84+
bool isUnique() const { return UniqueID != NonUniqueID; }
8585
unsigned getUniqueID() const { return UniqueID; }
8686

8787
const MCSection *getLinkedToSection() const {

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1670,8 +1670,9 @@ bool AsmPrinter::doFinalization(Module &M) {
16701670
GV.getVisibility() != GlobalValue::DefaultVisibility)
16711671
continue;
16721672

1673-
OutStreamer->SwitchSection(OutContext.getELFSection(
1674-
".llvm_sympart", ELF::SHT_LLVM_SYMPART, 0, 0, "", ++UniqueID));
1673+
OutStreamer->SwitchSection(
1674+
OutContext.getELFSection(".llvm_sympart", ELF::SHT_LLVM_SYMPART, 0, 0,
1675+
"", ++UniqueID, nullptr));
16751676
OutStreamer->emitBytes(GV.getPartition());
16761677
OutStreamer->EmitZeros(1);
16771678
OutStreamer->EmitValue(

llvm/lib/MC/MCContext.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,8 @@ MCSectionELF *MCContext::getELFSection(const Twine &Section, unsigned Type,
433433

434434
MCSectionELF *MCContext::createELFGroupSection(const MCSymbolELF *Group) {
435435
return createELFSectionImpl(".group", ELF::SHT_GROUP, 0,
436-
SectionKind::getReadOnly(), 4, Group, ~0,
437-
nullptr);
436+
SectionKind::getReadOnly(), 4, Group,
437+
MCSection::NonUniqueID, nullptr);
438438
}
439439

440440
MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,

llvm/lib/Target/ARM/ARMTargetObjectFile.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void ARMElfTargetObjectFile::Initialize(MCContext &Ctx,
4949
// Since we cannot modify flags for an existing section, we create a new
5050
// section with the right flags, and use 0 as the unique ID for
5151
// execute-only text
52-
TextSection = Ctx.getELFSection(".text", Type, Flags, 0, "", 0U);
52+
TextSection = Ctx.getELFSection(".text", Type, Flags, 0, "", 0U, nullptr);
5353
}
5454
}
5555

0 commit comments

Comments
 (0)