From 4c8edc741247df7d21d38d67d1bcc794d010d0a0 Mon Sep 17 00:00:00 2001 From: Alexis Engelke Date: Mon, 10 Jun 2024 20:22:41 +0200 Subject: [PATCH] [MC] Don't evaluate name of unnamed symbols There's only one way to create unnamed symbols (createTempSymbol). Previously, the name was evaluated unconditionally, but often unnecessarily. Avoid this. Also the parameter names in the header were wrong, fix these. --- llvm/include/llvm/MC/MCContext.h | 2 +- llvm/lib/MC/MCContext.cpp | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h index b0ac432a065bf..c560b62f802e5 100644 --- a/llvm/include/llvm/MC/MCContext.h +++ b/llvm/include/llvm/MC/MCContext.h @@ -371,7 +371,7 @@ class MCContext { std::function); MCSymbol *createSymbolImpl(const StringMapEntry *Name, - bool CanBeUnnamed); + bool IsTemporary); MCSymbol *createSymbol(StringRef Name, bool AlwaysAddSuffix, bool IsTemporary); diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 771ca9c6006ca..74b9f8d2addbc 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -264,13 +264,9 @@ MCSymbol *MCContext::createSymbolImpl(const StringMapEntry *Name, } MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix, - bool CanBeUnnamed) { - if (CanBeUnnamed && !UseNamesOnTempLabels) - return createSymbolImpl(nullptr, true); - + bool IsTemporary) { // Determine whether this is a user written assembler temporary or normal // label, if used. - bool IsTemporary = CanBeUnnamed; if (AllowTemporaryLabels && !IsTemporary) IsTemporary = Name.starts_with(MAI->getPrivateGlobalPrefix()); @@ -298,6 +294,9 @@ MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix, } MCSymbol *MCContext::createTempSymbol(const Twine &Name, bool AlwaysAddSuffix) { + if (!UseNamesOnTempLabels) + return createSymbolImpl(nullptr, /*IsTemporary=*/true); + SmallString<128> NameSV; raw_svector_ostream(NameSV) << MAI->getPrivateGlobalPrefix() << Name; return createSymbol(NameSV, AlwaysAddSuffix, true);