mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-26 05:25:47 +00:00
Make all temporary symbols unnamed.
What this does is make all symbols that would otherwise start with a .L (or L on MachO) unnamed. Some of these symbols still show up in the symbol table, but we can just make them unnamed. In order to make sure we produce identical results when going thought assembly, all .L (not just the compiler produced ones), are now unnamed. Running llc on llvm-as.opt.bc, the peak memory usage goes from 208.24MB to 205.57MB. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240130 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -116,7 +116,7 @@ MCSymbol *MCContext::getOrCreateSymbol(const Twine &Name) {
|
||||
|
||||
MCSymbol *&Sym = Symbols[NameRef];
|
||||
if (!Sym)
|
||||
Sym = createSymbol(NameRef, false, false);
|
||||
Sym = createSymbol(NameRef, false);
|
||||
|
||||
return Sym;
|
||||
}
|
||||
@@ -175,17 +175,16 @@ MCSymbol *MCContext::createSymbolImpl(const StringMapEntry<bool> *Name,
|
||||
IsTemporary);
|
||||
}
|
||||
|
||||
MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix,
|
||||
bool CanBeUnnamed) {
|
||||
if (CanBeUnnamed && !UseNamesOnTempLabels)
|
||||
return createSymbolImpl(nullptr, true);
|
||||
|
||||
MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix) {
|
||||
// Determine whether this is an user writter assembler temporary or normal
|
||||
// label, if used.
|
||||
bool IsTemporary = CanBeUnnamed;
|
||||
if (AllowTemporaryLabels && !IsTemporary)
|
||||
bool IsTemporary = false;
|
||||
if (AllowTemporaryLabels)
|
||||
IsTemporary = Name.startswith(MAI->getPrivateGlobalPrefix());
|
||||
|
||||
if (IsTemporary && !UseNamesOnTempLabels)
|
||||
return createSymbolImpl(nullptr, true);
|
||||
|
||||
SmallString<128> NewName = Name;
|
||||
bool AddSuffix = AlwaysAddSuffix;
|
||||
unsigned &NextUniqueID = NextID[Name];
|
||||
@@ -206,21 +205,20 @@ MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix,
|
||||
llvm_unreachable("Infinite loop");
|
||||
}
|
||||
|
||||
MCSymbol *MCContext::createTempSymbol(const Twine &Name, bool AlwaysAddSuffix,
|
||||
bool CanBeUnnamed) {
|
||||
MCSymbol *MCContext::createTempSymbol(const Twine &Name, bool AlwaysAddSuffix) {
|
||||
SmallString<128> NameSV;
|
||||
raw_svector_ostream(NameSV) << MAI->getPrivateGlobalPrefix() << Name;
|
||||
return createSymbol(NameSV, AlwaysAddSuffix, CanBeUnnamed);
|
||||
return createSymbol(NameSV, AlwaysAddSuffix);
|
||||
}
|
||||
|
||||
MCSymbol *MCContext::createLinkerPrivateTempSymbol() {
|
||||
SmallString<128> NameSV;
|
||||
raw_svector_ostream(NameSV) << MAI->getLinkerPrivateGlobalPrefix() << "tmp";
|
||||
return createSymbol(NameSV, true, false);
|
||||
return createSymbol(NameSV, true);
|
||||
}
|
||||
|
||||
MCSymbol *MCContext::createTempSymbol(bool CanBeUnnamed) {
|
||||
return createTempSymbol("tmp", true, CanBeUnnamed);
|
||||
MCSymbol *MCContext::createTempSymbol() {
|
||||
return createTempSymbol("tmp", true);
|
||||
}
|
||||
|
||||
unsigned MCContext::NextInstance(unsigned LocalLabelVal) {
|
||||
@@ -241,7 +239,7 @@ MCSymbol *MCContext::getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
|
||||
unsigned Instance) {
|
||||
MCSymbol *&Sym = LocalSymbols[std::make_pair(LocalLabelVal, Instance)];
|
||||
if (!Sym)
|
||||
Sym = createTempSymbol(false);
|
||||
Sym = createTempSymbol();
|
||||
return Sym;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user