X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FMC%2FMCContext.cpp;h=2160b4ee80d65fec18bda809d72a824b7c860940;hb=d3ca239fe8ccc6b1188d61130b887ebdc94f8059;hp=e8fb6a95ebe04896fce4898e5614c0b2b15fe526;hpb=b0a171f7a0c2516543e88d57dd3a3ae891b7f47d;p=oota-llvm.git diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index e8fb6a95ebe..2160b4ee80d 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -23,6 +23,7 @@ #include "llvm/MC/MCSymbolCOFF.h" #include "llvm/MC/MCSymbolELF.h" #include "llvm/MC/MCSymbolMachO.h" +#include "llvm/Support/COFF.h" #include "llvm/Support/ELF.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" @@ -73,15 +74,13 @@ MCContext::~MCContext() { void MCContext::reset() { // Call the destructors so the fragments are freed - for (auto &I : ELFUniquingMap) - I.second->~MCSectionELF(); - for (auto &I : COFFUniquingMap) - I.second->~MCSectionCOFF(); - for (auto &I : MachOUniquingMap) - I.second->~MCSectionMachO(); + COFFAllocator.DestroyAll(); + ELFAllocator.DestroyAll(); + MachOAllocator.DestroyAll(); UsedNames.clear(); Symbols.clear(); + SectionSymbols.clear(); Allocator.Reset(); Instances.clear(); CompilationDir.clear(); @@ -162,15 +161,13 @@ MCSymbol *MCContext::getOrCreateLSDASymbol(StringRef FuncName) { MCSymbol *MCContext::createSymbolImpl(const StringMapEntry *Name, bool IsTemporary) { if (MOFI) { - switch (MOFI->getTargetTriple().getObjectFormat()) { - case Triple::COFF: + switch (MOFI->getObjectFileType()) { + case MCObjectFileInfo::IsCOFF: return new (Name, *this) MCSymbolCOFF(Name, IsTemporary); - case Triple::ELF: + case MCObjectFileInfo::IsELF: return new (Name, *this) MCSymbolELF(Name, IsTemporary); - case Triple::MachO: + case MCObjectFileInfo::IsMachO: return new (Name, *this) MCSymbolMachO(Name, IsTemporary); - case Triple::UnknownObjectFormat: - break; } } return new (Name, *this) MCSymbol(MCSymbol::SymbolKindUnset, Name, @@ -295,8 +292,8 @@ MCSectionMachO *MCContext::getMachOSection(StringRef Segment, StringRef Section, Begin = createTempSymbol(BeginSymName, false); // Otherwise, return a new section. - return Entry = new (*this) MCSectionMachO(Segment, Section, TypeAndAttributes, - Reserved2, Kind, Begin); + return Entry = new (MachOAllocator.Allocate()) MCSectionMachO( + Segment, Section, TypeAndAttributes, Reserved2, Kind, Begin); } void MCContext::renameELFSection(MCSectionELF *Section, StringRef Name) { @@ -323,7 +320,7 @@ MCSectionELF *MCContext::createELFRelSection(StringRef Name, unsigned Type, bool Inserted; std::tie(I, Inserted) = ELFRelSecNames.insert(std::make_pair(Name, true)); - return new (*this) + return new (ELFAllocator.Allocate()) MCSectionELF(I->getKey(), Type, Flags, SectionKind::getReadOnly(), EntrySize, Group, true, nullptr, Associated); } @@ -368,15 +365,15 @@ MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, if (BeginSymName) Begin = createTempSymbol(BeginSymName, false); - MCSectionELF *Result = - new (*this) MCSectionELF(CachedName, Type, Flags, Kind, EntrySize, - GroupSym, UniqueID, Begin, Associated); + MCSectionELF *Result = new (ELFAllocator.Allocate()) + MCSectionELF(CachedName, Type, Flags, Kind, EntrySize, GroupSym, UniqueID, + Begin, Associated); Entry.second = Result; return Result; } MCSectionELF *MCContext::createELFGroupSection(const MCSymbolELF *Group) { - MCSectionELF *Result = new (*this) + MCSectionELF *Result = new (ELFAllocator.Allocate()) MCSectionELF(".group", ELF::SHT_GROUP, 0, SectionKind::getReadOnly(), 4, Group, ~0, nullptr, nullptr); return Result; @@ -405,7 +402,7 @@ MCSectionCOFF *MCContext::getCOFFSection(StringRef Section, Begin = createTempSymbol(BeginSymName, false); StringRef CachedName = Iter->first.SectionName; - MCSectionCOFF *Result = new (*this) MCSectionCOFF( + MCSectionCOFF *Result = new (COFFAllocator.Allocate()) MCSectionCOFF( CachedName, Characteristics, COMDATSymbol, Selection, Kind, Begin); Iter->second = Result;