[llvm] 1dc16c7 - [MC] Add MCSection::NonUniqueID and delete one MCContext::getELFSection overload
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 14 20:27:44 PST 2020
Author: Fangrui Song
Date: 2020-02-14T20:25:52-08:00
New Revision: 1dc16c752dd3dcd41ed320c2ea7647ea5bd7736e
URL: https://github.com/llvm/llvm-project/commit/1dc16c752dd3dcd41ed320c2ea7647ea5bd7736e
DIFF: https://github.com/llvm/llvm-project/commit/1dc16c752dd3dcd41ed320c2ea7647ea5bd7736e.diff
LOG: [MC] Add MCSection::NonUniqueID and delete one MCContext::getELFSection overload
Added:
Modified:
llvm/include/llvm/MC/MCContext.h
llvm/include/llvm/MC/MCSection.h
llvm/include/llvm/MC/MCSectionELF.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/MC/MCContext.cpp
llvm/lib/Target/ARM/ARMTargetObjectFile.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h
index e516ec8d5b19..7d2997967096 100644
--- a/llvm/include/llvm/MC/MCContext.h
+++ b/llvm/include/llvm/MC/MCContext.h
@@ -435,14 +435,8 @@ namespace llvm {
MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
unsigned Flags, unsigned EntrySize,
const Twine &Group) {
- return getELFSection(Section, Type, Flags, EntrySize, Group, ~0);
- }
-
- MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
- unsigned Flags, unsigned EntrySize,
- const Twine &Group, unsigned UniqueID) {
- return getELFSection(Section, Type, Flags, EntrySize, Group, UniqueID,
- nullptr);
+ return getELFSection(Section, Type, Flags, EntrySize, Group,
+ MCSection::NonUniqueID, nullptr);
}
MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
diff --git a/llvm/include/llvm/MC/MCSection.h b/llvm/include/llvm/MC/MCSection.h
index d80cc5b086b3..14283ead3433 100644
--- a/llvm/include/llvm/MC/MCSection.h
+++ b/llvm/include/llvm/MC/MCSection.h
@@ -38,6 +38,8 @@ template <> struct ilist_alloc_traits<MCFragment> {
/// current translation unit. The MCContext class uniques and creates these.
class MCSection {
public:
+ static constexpr unsigned NonUniqueID = ~0U;
+
enum SectionVariant { SV_COFF = 0, SV_ELF, SV_MachO, SV_Wasm, SV_XCOFF };
/// Express the state of bundle locked groups while emitting code.
diff --git a/llvm/include/llvm/MC/MCSectionELF.h b/llvm/include/llvm/MC/MCSectionELF.h
index 0fcbec558d9e..ef540d11cb26 100644
--- a/llvm/include/llvm/MC/MCSectionELF.h
+++ b/llvm/include/llvm/MC/MCSectionELF.h
@@ -81,7 +81,7 @@ class MCSectionELF final : public MCSection {
bool UseCodeAlign() const override;
bool isVirtualSection() const override;
- bool isUnique() const { return UniqueID != ~0U; }
+ bool isUnique() const { return UniqueID != NonUniqueID; }
unsigned getUniqueID() const { return UniqueID; }
const MCSection *getLinkedToSection() const {
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 9a7b541d17e4..261bdcaa4fa7 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1670,8 +1670,9 @@ bool AsmPrinter::doFinalization(Module &M) {
GV.getVisibility() != GlobalValue::DefaultVisibility)
continue;
- OutStreamer->SwitchSection(OutContext.getELFSection(
- ".llvm_sympart", ELF::SHT_LLVM_SYMPART, 0, 0, "", ++UniqueID));
+ OutStreamer->SwitchSection(
+ OutContext.getELFSection(".llvm_sympart", ELF::SHT_LLVM_SYMPART, 0, 0,
+ "", ++UniqueID, nullptr));
OutStreamer->emitBytes(GV.getPartition());
OutStreamer->EmitZeros(1);
OutStreamer->EmitValue(
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 8b3caf7838c6..6cda18adb881 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -433,8 +433,8 @@ MCSectionELF *MCContext::getELFSection(const Twine &Section, unsigned Type,
MCSectionELF *MCContext::createELFGroupSection(const MCSymbolELF *Group) {
return createELFSectionImpl(".group", ELF::SHT_GROUP, 0,
- SectionKind::getReadOnly(), 4, Group, ~0,
- nullptr);
+ SectionKind::getReadOnly(), 4, Group,
+ MCSection::NonUniqueID, nullptr);
}
MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
diff --git a/llvm/lib/Target/ARM/ARMTargetObjectFile.cpp b/llvm/lib/Target/ARM/ARMTargetObjectFile.cpp
index 891329d3f297..3f0e3360632d 100644
--- a/llvm/lib/Target/ARM/ARMTargetObjectFile.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetObjectFile.cpp
@@ -49,7 +49,7 @@ void ARMElfTargetObjectFile::Initialize(MCContext &Ctx,
// Since we cannot modify flags for an existing section, we create a new
// section with the right flags, and use 0 as the unique ID for
// execute-only text
- TextSection = Ctx.getELFSection(".text", Type, Flags, 0, "", 0U);
+ TextSection = Ctx.getELFSection(".text", Type, Flags, 0, "", 0U, nullptr);
}
}
More information about the llvm-commits
mailing list