summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCContext.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-04-04 18:02:01 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-04-04 18:02:01 +0000
commit8ca44f0b5ca7dbba81e1da5186ed30f4dc44152d (patch)
tree7327f2fc55e2e63800b1d5070ad1fc05516ac171 /llvm/lib/MC/MCContext.cpp
parentecc59396d1344f642a2ae5f6fc9e7cb3fb2fab9b (diff)
downloadbcm5719-llvm-8ca44f0b5ca7dbba81e1da5186ed30f4dc44152d.tar.gz
bcm5719-llvm-8ca44f0b5ca7dbba81e1da5186ed30f4dc44152d.zip
Implement unique sections with an unique ID.
This allows the compiler/assembly programmer to switch back to a section. This in turn fixes the bootstrap failure on powerpc (tested on gcc110) without changing the ppc codegen at all. I will try to cleanup the various getELFSection overloads in a followup patch. Just using a default argument now would lead to ambiguities. llvm-svn: 234099
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r--llvm/lib/MC/MCContext.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 6e7a3bc4db7..4443fc00fe0 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -273,9 +273,12 @@ void MCContext::renameELFSection(const MCSectionELF *Section, StringRef Name) {
if (const MCSymbol *Group = Section->getGroup())
GroupName = Group->getName();
- ELFUniquingMap.erase(ELFSectionKey{Section->getSectionName(), GroupName});
- auto I = ELFUniquingMap.insert(std::make_pair(ELFSectionKey{Name, GroupName},
- Section)).first;
+ unsigned UniqueID = Section->getUniqueID();
+ ELFUniquingMap.erase(
+ ELFSectionKey{Section->getSectionName(), GroupName, UniqueID});
+ auto I = ELFUniquingMap.insert(std::make_pair(
+ ELFSectionKey{Name, GroupName, UniqueID},
+ Section)).first;
StringRef CachedName = I->first.SectionName;
const_cast<MCSectionELF*>(Section)->setSectionName(CachedName);
}
@@ -294,7 +297,7 @@ MCContext::createELFRelSection(StringRef Name, unsigned Type, unsigned Flags,
const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
unsigned Flags, unsigned EntrySize,
- StringRef Group, bool Unique,
+ StringRef Group, unsigned UniqueID,
const char *BeginSymName) {
MCSymbol *GroupSym = nullptr;
if (!Group.empty()) {
@@ -304,9 +307,9 @@ const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
// Do the lookup, if we have a hit, return it.
auto IterBool = ELFUniquingMap.insert(
- std::make_pair(ELFSectionKey{Section, Group}, nullptr));
+ std::make_pair(ELFSectionKey{Section, Group, UniqueID}, nullptr));
auto &Entry = *IterBool.first;
- if (!IterBool.second && !Unique)
+ if (!IterBool.second)
return Entry.second;
StringRef CachedName = Entry.first.SectionName;
@@ -322,9 +325,8 @@ const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
Begin = createTempSymbol(BeginSymName, false);
MCSectionELF *Result = new (*this) MCSectionELF(
- CachedName, Type, Flags, Kind, EntrySize, GroupSym, Unique, Begin);
- if (!Unique)
- Entry.second = Result;
+ CachedName, Type, Flags, Kind, EntrySize, GroupSym, UniqueID, Begin);
+ Entry.second = Result;
return Result;
}
@@ -332,14 +334,14 @@ const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
unsigned Flags, unsigned EntrySize,
StringRef Group,
const char *BeginSymName) {
- return getELFSection(Section, Type, Flags, EntrySize, Group, false,
+ return getELFSection(Section, Type, Flags, EntrySize, Group, ~0,
BeginSymName);
}
const MCSectionELF *MCContext::CreateELFGroupSection() {
MCSectionELF *Result = new (*this)
MCSectionELF(".group", ELF::SHT_GROUP, 0, SectionKind::getReadOnly(), 4,
- nullptr, false, nullptr);
+ nullptr, ~0, nullptr);
return Result;
}
OpenPOWER on IntegriCloud