mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-27 15:57:13 +00:00
Use named temporaries for directional labels.
Directional labels can show up in symbol tables (and we have a llvm-mc test for that). Given that, we need to make sure they are named. With that out of the way, use setUseNamesOnTempLabels in llvm-mc so that it too benefits from the memory saving. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239914 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
aa94b68e1b
commit
b306ae3bf3
@ -207,7 +207,7 @@ namespace llvm {
|
|||||||
bool AutoReset;
|
bool AutoReset;
|
||||||
|
|
||||||
MCSymbol *createSymbolImpl(const StringMapEntry<bool> *Name,
|
MCSymbol *createSymbolImpl(const StringMapEntry<bool> *Name,
|
||||||
bool IsTemporary);
|
bool CanBeUnnamed);
|
||||||
MCSymbol *createSymbol(StringRef Name, bool AlwaysAddSuffix,
|
MCSymbol *createSymbol(StringRef Name, bool AlwaysAddSuffix,
|
||||||
bool IsTemporary);
|
bool IsTemporary);
|
||||||
|
|
||||||
@ -249,9 +249,10 @@ namespace llvm {
|
|||||||
|
|
||||||
/// Create and return a new assembler temporary symbol with a unique but
|
/// Create and return a new assembler temporary symbol with a unique but
|
||||||
/// unspecified name.
|
/// unspecified name.
|
||||||
MCSymbol *createTempSymbol();
|
MCSymbol *createTempSymbol(bool CanBeUnnamed = true);
|
||||||
|
|
||||||
MCSymbol *createTempSymbol(const Twine &Name, bool AlwaysAddSuffix);
|
MCSymbol *createTempSymbol(const Twine &Name, bool AlwaysAddSuffix,
|
||||||
|
bool CanBeUnnamed = true);
|
||||||
|
|
||||||
/// Create the definition of a directional local symbol for numbered label
|
/// Create the definition of a directional local symbol for numbered label
|
||||||
/// (used for "1:" definitions).
|
/// (used for "1:" definitions).
|
||||||
|
@ -176,14 +176,14 @@ MCSymbol *MCContext::createSymbolImpl(const StringMapEntry<bool> *Name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix,
|
MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix,
|
||||||
bool IsTemporary) {
|
bool CanBeUnnamed) {
|
||||||
if (IsTemporary && !UseNamesOnTempLabels)
|
if (CanBeUnnamed && !UseNamesOnTempLabels)
|
||||||
return createSymbolImpl(nullptr, true);
|
return createSymbolImpl(nullptr, true);
|
||||||
|
|
||||||
// Determine whether this is an user writter assembler temporary or normal
|
// Determine whether this is an user writter assembler temporary or normal
|
||||||
// label, if used.
|
// label, if used.
|
||||||
IsTemporary = false;
|
bool IsTemporary = CanBeUnnamed;
|
||||||
if (AllowTemporaryLabels)
|
if (AllowTemporaryLabels && !IsTemporary)
|
||||||
IsTemporary = Name.startswith(MAI->getPrivateGlobalPrefix());
|
IsTemporary = Name.startswith(MAI->getPrivateGlobalPrefix());
|
||||||
|
|
||||||
SmallString<128> NewName = Name;
|
SmallString<128> NewName = Name;
|
||||||
@ -206,10 +206,11 @@ MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix,
|
|||||||
llvm_unreachable("Infinite loop");
|
llvm_unreachable("Infinite loop");
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSymbol *MCContext::createTempSymbol(const Twine &Name, bool AlwaysAddSuffix) {
|
MCSymbol *MCContext::createTempSymbol(const Twine &Name, bool AlwaysAddSuffix,
|
||||||
|
bool CanBeUnnamed) {
|
||||||
SmallString<128> NameSV;
|
SmallString<128> NameSV;
|
||||||
raw_svector_ostream(NameSV) << MAI->getPrivateGlobalPrefix() << Name;
|
raw_svector_ostream(NameSV) << MAI->getPrivateGlobalPrefix() << Name;
|
||||||
return createSymbol(NameSV, AlwaysAddSuffix, true);
|
return createSymbol(NameSV, AlwaysAddSuffix, CanBeUnnamed);
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSymbol *MCContext::createLinkerPrivateTempSymbol() {
|
MCSymbol *MCContext::createLinkerPrivateTempSymbol() {
|
||||||
@ -218,8 +219,8 @@ MCSymbol *MCContext::createLinkerPrivateTempSymbol() {
|
|||||||
return createSymbol(NameSV, true, false);
|
return createSymbol(NameSV, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSymbol *MCContext::createTempSymbol() {
|
MCSymbol *MCContext::createTempSymbol(bool CanBeUnnamed) {
|
||||||
return createTempSymbol("tmp", true);
|
return createTempSymbol("tmp", true, CanBeUnnamed);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned MCContext::NextInstance(unsigned LocalLabelVal) {
|
unsigned MCContext::NextInstance(unsigned LocalLabelVal) {
|
||||||
@ -240,7 +241,7 @@ MCSymbol *MCContext::getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
|
|||||||
unsigned Instance) {
|
unsigned Instance) {
|
||||||
MCSymbol *&Sym = LocalSymbols[std::make_pair(LocalLabelVal, Instance)];
|
MCSymbol *&Sym = LocalSymbols[std::make_pair(LocalLabelVal, Instance)];
|
||||||
if (!Sym)
|
if (!Sym)
|
||||||
Sym = createTempSymbol();
|
Sym = createTempSymbol(false);
|
||||||
return Sym;
|
return Sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,6 +500,9 @@ int main(int argc, char **argv) {
|
|||||||
} else {
|
} else {
|
||||||
assert(FileType == OFT_ObjectFile && "Invalid file type!");
|
assert(FileType == OFT_ObjectFile && "Invalid file type!");
|
||||||
|
|
||||||
|
// Don't waste memory on names of temp labels.
|
||||||
|
Ctx.setUseNamesOnTempLabels(false);
|
||||||
|
|
||||||
if (!Out->os().supportsSeeking()) {
|
if (!Out->os().supportsSeeking()) {
|
||||||
BOS = make_unique<buffer_ostream>(Out->os());
|
BOS = make_unique<buffer_ostream>(Out->os());
|
||||||
OS = BOS.get();
|
OS = BOS.get();
|
||||||
|
Loading…
Reference in New Issue
Block a user