diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-05-21 19:20:38 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-05-21 19:20:38 +0000 |
commit | 0709a7bd1a75191a13580ca2a505fa0f7c4326bd (patch) | |
tree | d77dc6bcc145992fbd6a9deebe5e82c4aa553cae /llvm/lib/MC/MCContext.cpp | |
parent | 85d1965abd5e1d452e68e70473d856373c6ca845 (diff) | |
download | bcm5719-llvm-0709a7bd1a75191a13580ca2a505fa0f7c4326bd.tar.gz bcm5719-llvm-0709a7bd1a75191a13580ca2a505fa0f7c4326bd.zip |
Move alignment from MCSectionData to MCSection.
This starts merging MCSection and MCSectionData.
There are a few issues with the current split between MCSection and
MCSectionData.
* It optimizes the the not as important case. We want the production
of .o files to be really fast, but the split puts the information used
for .o emission in a separate data structure.
* The ELF/COFF/MachO hierarchy is not represented in MCSectionData,
leading to some ad-hoc ways to represent the various flags.
* It makes it harder to remember where each item is.
The attached patch starts merging the two by moving the alignment from
MCSectionData to MCSection.
Most of the patch is actually just dropping 'const', since
MCSectionData is mutable, but MCSection was not.
llvm-svn: 237936
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r-- | llvm/lib/MC/MCContext.cpp | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index cbc130f6bfa..f3ea3cc1691 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -241,10 +241,10 @@ MCSymbol *MCContext::lookupSymbol(const Twine &Name) const { // Section Management //===----------------------------------------------------------------------===// -const MCSectionMachO * -MCContext::getMachOSection(StringRef Segment, StringRef Section, - unsigned TypeAndAttributes, unsigned Reserved2, - SectionKind Kind, const char *BeginSymName) { +MCSectionMachO *MCContext::getMachOSection(StringRef Segment, StringRef Section, + unsigned TypeAndAttributes, + unsigned Reserved2, SectionKind Kind, + const char *BeginSymName) { // We unique sections by their segment/section pair. The returned section // may not have the same flags as the requested section, if so this should be @@ -257,7 +257,7 @@ MCContext::getMachOSection(StringRef Segment, StringRef Section, Name += Section; // Do the lookup, if we have a hit, return it. - const MCSectionMachO *&Entry = MachOUniquingMap[Name]; + MCSectionMachO *&Entry = MachOUniquingMap[Name]; if (Entry) return Entry; @@ -270,7 +270,7 @@ MCContext::getMachOSection(StringRef Segment, StringRef Section, Reserved2, Kind, Begin); } -void MCContext::renameELFSection(const MCSectionELF *Section, StringRef Name) { +void MCContext::renameELFSection(MCSectionELF *Section, StringRef Name) { StringRef GroupName; if (const MCSymbol *Group = Section->getGroup()) GroupName = Group->getName(); @@ -286,10 +286,10 @@ void MCContext::renameELFSection(const MCSectionELF *Section, StringRef Name) { const_cast<MCSectionELF *>(Section)->setSectionName(CachedName); } -const MCSectionELF * -MCContext::createELFRelSection(StringRef Name, unsigned Type, unsigned Flags, - unsigned EntrySize, const MCSymbol *Group, - const MCSectionELF *Associated) { +MCSectionELF *MCContext::createELFRelSection(StringRef Name, unsigned Type, + unsigned Flags, unsigned EntrySize, + const MCSymbol *Group, + const MCSectionELF *Associated) { StringMap<bool>::iterator I; bool Inserted; std::tie(I, Inserted) = ELFRelSecNames.insert(std::make_pair(Name, true)); @@ -299,10 +299,10 @@ MCContext::createELFRelSection(StringRef Name, unsigned Type, unsigned Flags, EntrySize, Group, true, nullptr, Associated); } -const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, - unsigned Flags, unsigned EntrySize, - StringRef Group, unsigned UniqueID, - const char *BeginSymName) { +MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, + unsigned Flags, unsigned EntrySize, + StringRef Group, unsigned UniqueID, + const char *BeginSymName) { MCSymbol *GroupSym = nullptr; if (!Group.empty()) GroupSym = getOrCreateSymbol(Group); @@ -311,12 +311,12 @@ const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, BeginSymName, nullptr); } -const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, - unsigned Flags, unsigned EntrySize, - const MCSymbol *GroupSym, - unsigned UniqueID, - const char *BeginSymName, - const MCSectionELF *Associated) { +MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, + unsigned Flags, unsigned EntrySize, + const MCSymbol *GroupSym, + unsigned UniqueID, + const char *BeginSymName, + const MCSectionELF *Associated) { StringRef Group = ""; if (GroupSym) Group = GroupSym->getName(); @@ -346,17 +346,18 @@ const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, return Result; } -const MCSectionELF *MCContext::createELFGroupSection(const MCSymbol *Group) { +MCSectionELF *MCContext::createELFGroupSection(const MCSymbol *Group) { MCSectionELF *Result = new (*this) MCSectionELF(".group", ELF::SHT_GROUP, 0, SectionKind::getReadOnly(), 4, Group, ~0, nullptr, nullptr); return Result; } -const MCSectionCOFF * -MCContext::getCOFFSection(StringRef Section, unsigned Characteristics, - SectionKind Kind, StringRef COMDATSymName, - int Selection, const char *BeginSymName) { +MCSectionCOFF *MCContext::getCOFFSection(StringRef Section, + unsigned Characteristics, + SectionKind Kind, + StringRef COMDATSymName, int Selection, + const char *BeginSymName) { MCSymbol *COMDATSymbol = nullptr; if (!COMDATSymName.empty()) { COMDATSymbol = getOrCreateSymbol(COMDATSymName); @@ -382,14 +383,14 @@ MCContext::getCOFFSection(StringRef Section, unsigned Characteristics, return Result; } -const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section, - unsigned Characteristics, - SectionKind Kind, - const char *BeginSymName) { +MCSectionCOFF *MCContext::getCOFFSection(StringRef Section, + unsigned Characteristics, + SectionKind Kind, + const char *BeginSymName) { return getCOFFSection(Section, Characteristics, Kind, "", 0, BeginSymName); } -const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section) { +MCSectionCOFF *MCContext::getCOFFSection(StringRef Section) { COFFSectionKey T{Section, "", 0}; auto Iter = COFFUniquingMap.find(T); if (Iter == COFFUniquingMap.end()) @@ -397,9 +398,8 @@ const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section) { return Iter->second; } -const MCSectionCOFF * -MCContext::getAssociativeCOFFSection(const MCSectionCOFF *Sec, - const MCSymbol *KeySym) { +MCSectionCOFF *MCContext::getAssociativeCOFFSection(MCSectionCOFF *Sec, + const MCSymbol *KeySym) { // Return the normal section if we don't have to be associative. if (!KeySym) return Sec; @@ -440,8 +440,8 @@ bool MCContext::isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID) { /// Remove empty sections from SectionStartEndSyms, to avoid generating /// useless debug info for them. void MCContext::finalizeDwarfSections(MCStreamer &MCOS) { - std::vector<const MCSection *> Keep; - for (const MCSection *Sec : SectionsForRanges) { + std::vector<MCSection *> Keep; + for (MCSection *Sec : SectionsForRanges) { if (MCOS.mayHaveInstructions(*Sec)) Keep.push_back(Sec); } |