mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-21 06:30:16 +00:00
Remove lazy-initialization of section caches in MCContext
This seems to have been a cargo-culted habit from the very first such cache which didn't have any specific justification (but might've been a layering constraint at the time). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206003 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bc1fd917f0
commit
42382d3e37
@ -155,7 +155,11 @@ namespace llvm {
|
|||||||
/// The Compile Unit ID that we are currently processing.
|
/// The Compile Unit ID that we are currently processing.
|
||||||
unsigned DwarfCompileUnitID;
|
unsigned DwarfCompileUnitID;
|
||||||
|
|
||||||
void *MachOUniquingMap, *ELFUniquingMap, *COFFUniquingMap;
|
typedef std::pair<std::string, std::string> SectionGroupPair;
|
||||||
|
|
||||||
|
StringMap<const MCSectionMachO*> MachOUniquingMap;
|
||||||
|
std::map<SectionGroupPair, const MCSectionELF *> ELFUniquingMap;
|
||||||
|
std::map<SectionGroupPair, const MCSectionCOFF *> COFFUniquingMap;
|
||||||
|
|
||||||
/// Do automatic reset in destructor
|
/// Do automatic reset in destructor
|
||||||
bool AutoReset;
|
bool AutoReset;
|
||||||
|
@ -29,12 +29,6 @@
|
|||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
typedef std::pair<std::string, std::string> SectionGroupPair;
|
|
||||||
|
|
||||||
typedef StringMap<const MCSectionMachO*> MachOUniqueMapTy;
|
|
||||||
typedef std::map<SectionGroupPair, const MCSectionELF *> ELFUniqueMapTy;
|
|
||||||
typedef std::map<SectionGroupPair, const MCSectionCOFF *> COFFUniqueMapTy;
|
|
||||||
|
|
||||||
MCContext::MCContext(const MCAsmInfo *mai, const MCRegisterInfo *mri,
|
MCContext::MCContext(const MCAsmInfo *mai, const MCRegisterInfo *mri,
|
||||||
const MCObjectFileInfo *mofi, const SourceMgr *mgr,
|
const MCObjectFileInfo *mofi, const SourceMgr *mgr,
|
||||||
bool DoAutoReset)
|
bool DoAutoReset)
|
||||||
@ -49,10 +43,6 @@ MCContext::MCContext(const MCAsmInfo *mai, const MCRegisterInfo *mri,
|
|||||||
if (EC)
|
if (EC)
|
||||||
CompilationDir.clear();
|
CompilationDir.clear();
|
||||||
|
|
||||||
MachOUniquingMap = 0;
|
|
||||||
ELFUniquingMap = 0;
|
|
||||||
COFFUniquingMap = 0;
|
|
||||||
|
|
||||||
SecureLogFile = getenv("AS_SECURE_LOG_FILE");
|
SecureLogFile = getenv("AS_SECURE_LOG_FILE");
|
||||||
SecureLog = 0;
|
SecureLog = 0;
|
||||||
SecureLogUsed = false;
|
SecureLogUsed = false;
|
||||||
@ -88,13 +78,9 @@ void MCContext::reset() {
|
|||||||
DwarfCompileUnitID = 0;
|
DwarfCompileUnitID = 0;
|
||||||
CurrentDwarfLoc = MCDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0);
|
CurrentDwarfLoc = MCDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0);
|
||||||
|
|
||||||
// If we have the MachO uniquing map, free it.
|
MachOUniquingMap.clear();
|
||||||
delete (MachOUniqueMapTy*)MachOUniquingMap;
|
ELFUniquingMap.clear();
|
||||||
delete (ELFUniqueMapTy*)ELFUniquingMap;
|
COFFUniquingMap.clear();
|
||||||
delete (COFFUniqueMapTy*)COFFUniquingMap;
|
|
||||||
MachOUniquingMap = 0;
|
|
||||||
ELFUniquingMap = 0;
|
|
||||||
COFFUniquingMap = 0;
|
|
||||||
|
|
||||||
NextUniqueID = 0;
|
NextUniqueID = 0;
|
||||||
AllowTemporaryLabels = true;
|
AllowTemporaryLabels = true;
|
||||||
@ -225,11 +211,6 @@ getMachOSection(StringRef Segment, StringRef Section,
|
|||||||
// may not have the same flags as the requested section, if so this should be
|
// may not have the same flags as the requested section, if so this should be
|
||||||
// diagnosed by the client as an error.
|
// diagnosed by the client as an error.
|
||||||
|
|
||||||
// Create the map if it doesn't already exist.
|
|
||||||
if (MachOUniquingMap == 0)
|
|
||||||
MachOUniquingMap = new MachOUniqueMapTy();
|
|
||||||
MachOUniqueMapTy &Map = *(MachOUniqueMapTy*)MachOUniquingMap;
|
|
||||||
|
|
||||||
// Form the name to look up.
|
// Form the name to look up.
|
||||||
SmallString<64> Name;
|
SmallString<64> Name;
|
||||||
Name += Segment;
|
Name += Segment;
|
||||||
@ -237,7 +218,7 @@ getMachOSection(StringRef Segment, StringRef Section,
|
|||||||
Name += Section;
|
Name += Section;
|
||||||
|
|
||||||
// Do the lookup, if we have a hit, return it.
|
// Do the lookup, if we have a hit, return it.
|
||||||
const MCSectionMachO *&Entry = Map[Name.str()];
|
const MCSectionMachO *&Entry = MachOUniquingMap[Name.str()];
|
||||||
if (Entry) return Entry;
|
if (Entry) return Entry;
|
||||||
|
|
||||||
// Otherwise, return a new section.
|
// Otherwise, return a new section.
|
||||||
@ -252,31 +233,25 @@ getELFSection(StringRef Section, unsigned Type, unsigned Flags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MCContext::renameELFSection(const MCSectionELF *Section, StringRef Name) {
|
void MCContext::renameELFSection(const MCSectionELF *Section, StringRef Name) {
|
||||||
if (ELFUniquingMap == 0)
|
|
||||||
ELFUniquingMap = new ELFUniqueMapTy();
|
|
||||||
ELFUniqueMapTy &Map = *(ELFUniqueMapTy*)ELFUniquingMap;
|
|
||||||
|
|
||||||
StringRef GroupName;
|
StringRef GroupName;
|
||||||
if (const MCSymbol *Group = Section->getGroup())
|
if (const MCSymbol *Group = Section->getGroup())
|
||||||
GroupName = Group->getName();
|
GroupName = Group->getName();
|
||||||
|
|
||||||
Map.erase(SectionGroupPair(Section->getSectionName(), GroupName));
|
ELFUniquingMap.erase(SectionGroupPair(Section->getSectionName(), GroupName));
|
||||||
auto I = Map.insert(std::make_pair(SectionGroupPair(Name, GroupName),
|
auto I =
|
||||||
Section)).first;
|
ELFUniquingMap.insert(std::make_pair(SectionGroupPair(Name, GroupName),
|
||||||
|
Section)).first;
|
||||||
const_cast<MCSectionELF*>(Section)->setSectionName(I->first.first);
|
const_cast<MCSectionELF*>(Section)->setSectionName(I->first.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
const MCSectionELF *MCContext::
|
const MCSectionELF *MCContext::
|
||||||
getELFSection(StringRef Section, unsigned Type, unsigned Flags,
|
getELFSection(StringRef Section, unsigned Type, unsigned Flags,
|
||||||
SectionKind Kind, unsigned EntrySize, StringRef Group) {
|
SectionKind Kind, unsigned EntrySize, StringRef Group) {
|
||||||
if (ELFUniquingMap == 0)
|
|
||||||
ELFUniquingMap = new ELFUniqueMapTy();
|
|
||||||
ELFUniqueMapTy &Map = *(ELFUniqueMapTy*)ELFUniquingMap;
|
|
||||||
|
|
||||||
// Do the lookup, if we have a hit, return it.
|
// Do the lookup, if we have a hit, return it.
|
||||||
std::pair<ELFUniqueMapTy::iterator, bool> Entry = Map.insert(
|
auto IterBool = ELFUniquingMap.insert(
|
||||||
std::make_pair(SectionGroupPair(Section, Group), (MCSectionELF *)0));
|
std::make_pair(SectionGroupPair(Section, Group), (MCSectionELF *)0));
|
||||||
if (!Entry.second) return Entry.first->second;
|
auto &Entry = *IterBool.first;
|
||||||
|
if (!IterBool.second) return Entry.second;
|
||||||
|
|
||||||
// Possibly refine the entry size first.
|
// Possibly refine the entry size first.
|
||||||
if (!EntrySize) {
|
if (!EntrySize) {
|
||||||
@ -288,8 +263,8 @@ getELFSection(StringRef Section, unsigned Type, unsigned Flags,
|
|||||||
GroupSym = GetOrCreateSymbol(Group);
|
GroupSym = GetOrCreateSymbol(Group);
|
||||||
|
|
||||||
MCSectionELF *Result = new (*this) MCSectionELF(
|
MCSectionELF *Result = new (*this) MCSectionELF(
|
||||||
Entry.first->first.first, Type, Flags, Kind, EntrySize, GroupSym);
|
Entry.first.first, Type, Flags, Kind, EntrySize, GroupSym);
|
||||||
Entry.first->second = Result;
|
Entry.second = Result;
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,17 +279,12 @@ const MCSectionCOFF *
|
|||||||
MCContext::getCOFFSection(StringRef Section, unsigned Characteristics,
|
MCContext::getCOFFSection(StringRef Section, unsigned Characteristics,
|
||||||
SectionKind Kind, StringRef COMDATSymName,
|
SectionKind Kind, StringRef COMDATSymName,
|
||||||
int Selection, const MCSectionCOFF *Assoc) {
|
int Selection, const MCSectionCOFF *Assoc) {
|
||||||
if (COFFUniquingMap == 0)
|
|
||||||
COFFUniquingMap = new COFFUniqueMapTy();
|
|
||||||
COFFUniqueMapTy &Map = *(COFFUniqueMapTy*)COFFUniquingMap;
|
|
||||||
|
|
||||||
// Do the lookup, if we have a hit, return it.
|
// Do the lookup, if we have a hit, return it.
|
||||||
|
|
||||||
SectionGroupPair P(Section, COMDATSymName);
|
SectionGroupPair P(Section, COMDATSymName);
|
||||||
std::pair<COFFUniqueMapTy::iterator, bool> Entry =
|
auto IterBool = COFFUniquingMap.insert(std::make_pair(P, (MCSectionCOFF *)0));
|
||||||
Map.insert(std::make_pair(P, (MCSectionCOFF *)0));
|
auto Iter = IterBool.first;
|
||||||
COFFUniqueMapTy::iterator Iter = Entry.first;
|
if (!IterBool.second)
|
||||||
if (!Entry.second)
|
|
||||||
return Iter->second;
|
return Iter->second;
|
||||||
|
|
||||||
const MCSymbol *COMDATSymbol = NULL;
|
const MCSymbol *COMDATSymbol = NULL;
|
||||||
@ -336,13 +306,9 @@ MCContext::getCOFFSection(StringRef Section, unsigned Characteristics,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section) {
|
const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section) {
|
||||||
if (COFFUniquingMap == 0)
|
|
||||||
COFFUniquingMap = new COFFUniqueMapTy();
|
|
||||||
COFFUniqueMapTy &Map = *(COFFUniqueMapTy*)COFFUniquingMap;
|
|
||||||
|
|
||||||
SectionGroupPair P(Section, "");
|
SectionGroupPair P(Section, "");
|
||||||
COFFUniqueMapTy::iterator Iter = Map.find(P);
|
auto Iter = COFFUniquingMap.find(P);
|
||||||
if (Iter == Map.end())
|
if (Iter == COFFUniquingMap.end())
|
||||||
return 0;
|
return 0;
|
||||||
return Iter->second;
|
return Iter->second;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user