diff options
author | Reid Kleckner <rnk@google.com> | 2016-05-02 23:22:18 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2016-05-02 23:22:18 +0000 |
commit | 97837b7b091621537854a753942ce504560dee45 (patch) | |
tree | 60abc8f455f43edab5d3d423b2439e01c5f33718 /llvm/lib/MC/MCContext.cpp | |
parent | 9102fc20f8e3d89b27d91a23a9a50ae32bf403c4 (diff) | |
download | bcm5719-llvm-97837b7b091621537854a753942ce504560dee45.tar.gz bcm5719-llvm-97837b7b091621537854a753942ce504560dee45.zip |
[MC] Create unique .pdata sections for every .text section
Summary:
This adds a unique ID to the COFF section uniquing map, similar to the
one we have for ELF. The unique id is not currently exposed via the
assembler because we don't have a use case for it yet. Users generally
create .pdata with the .seh_* family of directives, and the assembler
internally needs to produce .pdata and .xdata sections corresponding to
the code section.
The association between .text sections and the assembler-created .xdata
and .pdata sections is maintained as an ID field of MCSectionCOFF. The
CFI-related sections are created with the given unique ID, so if more
code is added to the same text section, we can find and reuse the CFI
sections that were already created.
Reviewers: majnemer, rafael
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D19376
llvm-svn: 268331
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r-- | llvm/lib/MC/MCContext.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 48dd89f0d38..67463e583d7 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -372,6 +372,7 @@ MCSectionCOFF *MCContext::getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, + unsigned UniqueID, const char *BeginSymName) { MCSymbol *COMDATSymbol = nullptr; if (!COMDATSymName.empty()) { @@ -379,8 +380,9 @@ MCSectionCOFF *MCContext::getCOFFSection(StringRef Section, COMDATSymName = COMDATSymbol->getName(); } + // Do the lookup, if we have a hit, return it. - COFFSectionKey T{Section, COMDATSymName, Selection}; + COFFSectionKey T{Section, COMDATSymName, Selection, UniqueID}; auto IterBool = COFFUniquingMap.insert(std::make_pair(T, nullptr)); auto Iter = IterBool.first; if (!IterBool.second) @@ -402,11 +404,12 @@ MCSectionCOFF *MCContext::getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, const char *BeginSymName) { - return getCOFFSection(Section, Characteristics, Kind, "", 0, BeginSymName); + return getCOFFSection(Section, Characteristics, Kind, "", 0, GenericSectionID, + BeginSymName); } MCSectionCOFF *MCContext::getCOFFSection(StringRef Section) { - COFFSectionKey T{Section, "", 0}; + COFFSectionKey T{Section, "", 0, GenericSectionID}; auto Iter = COFFUniquingMap.find(T); if (Iter == COFFUniquingMap.end()) return nullptr; @@ -414,18 +417,24 @@ MCSectionCOFF *MCContext::getCOFFSection(StringRef Section) { } MCSectionCOFF *MCContext::getAssociativeCOFFSection(MCSectionCOFF *Sec, - const MCSymbol *KeySym) { - // Return the normal section if we don't have to be associative. - if (!KeySym) + const MCSymbol *KeySym, + unsigned UniqueID) { + // Return the normal section if we don't have to be associative or unique. + if (!KeySym && UniqueID == GenericSectionID) return Sec; - // Make an associative section with the same name and kind as the normal - // section. - unsigned Characteristics = - Sec->getCharacteristics() | COFF::IMAGE_SCN_LNK_COMDAT; + // If we have a key symbol, make an associative section with the same name and + // kind as the normal section. + unsigned Characteristics = Sec->getCharacteristics(); + if (KeySym) { + Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT; + return getCOFFSection(Sec->getSectionName(), Characteristics, + Sec->getKind(), KeySym->getName(), + COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE, UniqueID); + } + return getCOFFSection(Sec->getSectionName(), Characteristics, Sec->getKind(), - KeySym->getName(), - COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE); + "", 0, UniqueID); } MCSubtargetInfo &MCContext::getSubtargetCopy(const MCSubtargetInfo &STI) { |