diff options
| author | Eric Christopher <echristo@gmail.com> | 2016-07-01 06:07:38 +0000 |
|---|---|---|
| committer | Eric Christopher <echristo@gmail.com> | 2016-07-01 06:07:38 +0000 |
| commit | 36e601c6dcd8c30486897c626e017700817d1d73 (patch) | |
| tree | 7110b13d3795d02b0cadb04235e56ce77c5b6839 /llvm/lib/MC | |
| parent | 0b6537e6e55bb74b6b39b7961a78e1d1a46416e3 (diff) | |
| download | bcm5719-llvm-36e601c6dcd8c30486897c626e017700817d1d73.tar.gz bcm5719-llvm-36e601c6dcd8c30486897c626e017700817d1d73.zip | |
Add support for allowing us to create uniquely identified "COMDAT" or "ELF
Group" sections while lowering. In particular, for ELF sections this is
useful for creating function-specific groups that get merged into the
same named section.
Also use const Twine& instead of StringRef for the getELF functions
while we're here.
Differential Revision: http://reviews.llvm.org/D21743
llvm-svn: 274336
Diffstat (limited to 'llvm/lib/MC')
| -rw-r--r-- | llvm/lib/MC/MCContext.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index f48ab2f8e34..47ed1ca3add 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -309,32 +309,40 @@ void MCContext::renameELFSection(MCSectionELF *Section, StringRef Name) { const_cast<MCSectionELF *>(Section)->setSectionName(CachedName); } -MCSectionELF *MCContext::createELFRelSection(StringRef Name, unsigned Type, +MCSectionELF *MCContext::createELFRelSection(const Twine &Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *Associated) { StringMap<bool>::iterator I; bool Inserted; - std::tie(I, Inserted) = ELFRelSecNames.insert(std::make_pair(Name, true)); + std::tie(I, Inserted) = + ELFRelSecNames.insert(std::make_pair(Name.str(), true)); return new (ELFAllocator.Allocate()) MCSectionELF(I->getKey(), Type, Flags, SectionKind::getReadOnly(), EntrySize, Group, true, nullptr, Associated); } -MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, +MCSectionELF *MCContext::getELFNamedSection(const Twine &Prefix, + const Twine &Suffix, unsigned Type, + unsigned Flags, + unsigned EntrySize) { + return getELFSection(Prefix + "." + Suffix, Type, Flags, EntrySize, Suffix); +} + +MCSectionELF *MCContext::getELFSection(const Twine &Section, unsigned Type, unsigned Flags, unsigned EntrySize, - StringRef Group, unsigned UniqueID, + const Twine &Group, unsigned UniqueID, const char *BeginSymName) { MCSymbolELF *GroupSym = nullptr; - if (!Group.empty()) + if (!Group.isTriviallyEmpty() && !Group.str().empty()) GroupSym = cast<MCSymbolELF>(getOrCreateSymbol(Group)); return getELFSection(Section, Type, Flags, EntrySize, GroupSym, UniqueID, BeginSymName, nullptr); } -MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, +MCSectionELF *MCContext::getELFSection(const Twine &Section, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *GroupSym, unsigned UniqueID, @@ -345,7 +353,7 @@ MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, Group = GroupSym->getName(); // Do the lookup, if we have a hit, return it. auto IterBool = ELFUniquingMap.insert( - std::make_pair(ELFSectionKey{Section, Group, UniqueID}, nullptr)); + std::make_pair(ELFSectionKey{Section.str(), Group, UniqueID}, nullptr)); auto &Entry = *IterBool.first; if (!IterBool.second) return Entry.second; |

