move macho section uniquing from MCParser and TLOF to MCContext where

the compiler and asmparser now unique to the same sections.  This fixes
rdar://7835021.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100807 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2010-04-08 20:30:37 +00:00
parent a57fabe815
commit f0559e4b24
7 changed files with 87 additions and 106 deletions

View File

@@ -426,40 +426,14 @@ getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
// MachO
//===----------------------------------------------------------------------===//
typedef StringMap<const MCSectionMachO*> MachOUniqueMapTy;
TargetLoweringObjectFileMachO::~TargetLoweringObjectFileMachO() {
// If we have the MachO uniquing map, free it.
delete (MachOUniqueMapTy*)UniquingMap;
}
const MCSectionMachO *TargetLoweringObjectFileMachO::
getMachOSection(StringRef Segment, StringRef Section,
unsigned TypeAndAttributes,
unsigned Reserved2, SectionKind Kind) const {
// 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
// diagnosed by the client as an error.
// Create the map if it doesn't already exist.
if (UniquingMap == 0)
UniquingMap = new MachOUniqueMapTy();
MachOUniqueMapTy &Map = *(MachOUniqueMapTy*)UniquingMap;
// Form the name to look up.
SmallString<64> Name;
Name += Segment;
Name.push_back(',');
Name += Section;
// Do the lookup, if we have a hit, return it.
const MCSectionMachO *&Entry = Map[Name.str()];
if (Entry) return Entry;
// Otherwise, return a new section.
return Entry = MCSectionMachO::Create(Segment, Section, TypeAndAttributes,
Reserved2, Kind, getContext());
return getContext().getMachOSection(Segment, Section, TypeAndAttributes,
Reserved2, Kind);
}
@@ -473,8 +447,6 @@ void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx,
IsFunctionEHFrameSymbolPrivate = false;
SupportsWeakOmittedEHFrame = false;
if (UniquingMap != 0)
((MachOUniqueMapTy*)UniquingMap)->clear();
TargetLoweringObjectFile::Initialize(Ctx, TM);
TextSection // .text
@@ -806,7 +778,7 @@ const MCSection *TargetLoweringObjectFileCOFF::
getCOFFSection(StringRef Name, bool isDirective, SectionKind Kind) const {
// Create the map if it doesn't already exist.
if (UniquingMap == 0)
UniquingMap = new MachOUniqueMapTy();
UniquingMap = new COFFUniqueMapTy();
COFFUniqueMapTy &Map = *(COFFUniqueMapTy*)UniquingMap;
// Do the lookup, if we have a hit, return it.