diff options
author | Chris Lattner <sabre@nondot.org> | 2009-08-13 00:37:15 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-08-13 00:37:15 +0000 |
commit | 04b4700ebcec1f877cef4f87979b82f29969f3af (patch) | |
tree | c6e9db8e74eb56f944a7f4150d873a004ed8aa10 /llvm/lib/Target/TargetLoweringObjectFile.cpp | |
parent | 6bb66bbd0661028ee007cbe62c7045a166ab95d4 (diff) | |
download | llvm-04b4700ebcec1f877cef4f87979b82f29969f3af.zip llvm-04b4700ebcec1f877cef4f87979b82f29969f3af.tar.gz llvm-04b4700ebcec1f877cef4f87979b82f29969f3af.tar.bz2 |
sink uniquing of sections out of MCContext into the ELF and PECOFF TLOF implementations.
MCContext no longer maintains a string -> section map.
llvm-svn: 78874
Diffstat (limited to 'llvm/lib/Target/TargetLoweringObjectFile.cpp')
-rw-r--r-- | llvm/lib/Target/TargetLoweringObjectFile.cpp | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/llvm/lib/Target/TargetLoweringObjectFile.cpp b/llvm/lib/Target/TargetLoweringObjectFile.cpp index e7680c8..00f4ffe 100644 --- a/llvm/lib/Target/TargetLoweringObjectFile.cpp +++ b/llvm/lib/Target/TargetLoweringObjectFile.cpp @@ -280,12 +280,25 @@ TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind) const { //===----------------------------------------------------------------------===// // ELF //===----------------------------------------------------------------------===// +typedef StringMap<const MCSectionELF*> ELFUniqueMapTy; + +TargetLoweringObjectFileELF::~TargetLoweringObjectFileELF() { + // If we have the section uniquing map, free it. + delete (ELFUniqueMapTy*)UniquingMap; +} const MCSection *TargetLoweringObjectFileELF:: getELFSection(const char *Name, bool isDirective, SectionKind Kind) const { - if (MCSection *S = getContext().GetSection(Name)) - return S; - return MCSectionELF::Create(Name, isDirective, Kind, getContext()); + // Create the map if it doesn't already exist. + if (UniquingMap == 0) + UniquingMap = new ELFUniqueMapTy(); + ELFUniqueMapTy &Map = *(ELFUniqueMapTy*)UniquingMap; + + // Do the lookup, if we have a hit, return it. + const MCSectionELF *&Entry = Map[Name]; + if (Entry) return Entry; + + return Entry = MCSectionELF::Create(Name, isDirective, Kind, getContext()); } void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx, @@ -805,12 +818,25 @@ shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler *Mang) const { // COFF //===----------------------------------------------------------------------===// +typedef StringMap<const MCSectionCOFF*> COFFUniqueMapTy; + +TargetLoweringObjectFileCOFF::~TargetLoweringObjectFileCOFF() { + delete (COFFUniqueMapTy*)UniquingMap; +} + const MCSection *TargetLoweringObjectFileCOFF:: getCOFFSection(const char *Name, bool isDirective, SectionKind Kind) const { - if (MCSection *S = getContext().GetSection(Name)) - return S; - return MCSectionCOFF::Create(Name, isDirective, Kind, getContext()); + // Create the map if it doesn't already exist. + if (UniquingMap == 0) + UniquingMap = new MachOUniqueMapTy(); + COFFUniqueMapTy &Map = *(COFFUniqueMapTy*)UniquingMap; + + // Do the lookup, if we have a hit, return it. + const MCSectionCOFF *&Entry = Map[Name]; + if (Entry) return Entry; + + return Entry = MCSectionCOFF::Create(Name, isDirective, Kind, getContext()); } void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx, |