summaryrefslogtreecommitdiffstats
path: root/lib/MC/MCContext.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-10-22 23:41:52 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-10-22 23:41:52 +0000
commit2b3ea3cdad927cb0e346dd24e9bf84f8eb83babf (patch)
tree9f3e7575ee060cc4efe92e3168bb625168817418 /lib/MC/MCContext.cpp
parentf45787c645cdf9fb9e0f65b77d48630579a6d3e3 (diff)
downloadexternal_llvm-2b3ea3cdad927cb0e346dd24e9bf84f8eb83babf.zip
external_llvm-2b3ea3cdad927cb0e346dd24e9bf84f8eb83babf.tar.gz
external_llvm-2b3ea3cdad927cb0e346dd24e9bf84f8eb83babf.tar.bz2
MC: Support multiple sections with the same name in the same comdat group
Code review by Eric Christopher and Rafael Espindola. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193209 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCContext.cpp')
-rw-r--r--lib/MC/MCContext.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp
index 6e4d82b..67904f6 100644
--- a/lib/MC/MCContext.cpp
+++ b/lib/MC/MCContext.cpp
@@ -25,10 +25,15 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/SourceMgr.h"
+
+#include <map>
+
using namespace llvm;
+typedef std::pair<std::string, std::string> SectionGroupPair;
+
typedef StringMap<const MCSectionMachO*> MachOUniqueMapTy;
-typedef StringMap<const MCSectionELF*> ELFUniqueMapTy;
+typedef std::map<SectionGroupPair, const MCSectionELF *> ELFUniqueMapTy;
typedef StringMap<const MCSectionCOFF*> COFFUniqueMapTy;
@@ -249,8 +254,9 @@ getELFSection(StringRef Section, unsigned Type, unsigned Flags,
ELFUniqueMapTy &Map = *(ELFUniqueMapTy*)ELFUniquingMap;
// Do the lookup, if we have a hit, return it.
- StringMapEntry<const MCSectionELF*> &Entry = Map.GetOrCreateValue(Section);
- if (Entry.getValue()) return Entry.getValue();
+ std::pair<ELFUniqueMapTy::iterator, bool> Entry = Map.insert(
+ std::make_pair(SectionGroupPair(Section, Group), (MCSectionELF *)0));
+ if (!Entry.second) return Entry.first->second;
// Possibly refine the entry size first.
if (!EntrySize) {
@@ -261,9 +267,9 @@ getELFSection(StringRef Section, unsigned Type, unsigned Flags,
if (!Group.empty())
GroupSym = GetOrCreateSymbol(Group);
- MCSectionELF *Result = new (*this) MCSectionELF(Entry.getKey(), Type, Flags,
- Kind, EntrySize, GroupSym);
- Entry.setValue(Result);
+ MCSectionELF *Result = new (*this) MCSectionELF(
+ Entry.first->first.first, Type, Flags, Kind, EntrySize, GroupSym);
+ Entry.first->second = Result;
return Result;
}