[llvm] 4322997 - [MC] Don't evaluate name of unnamed symbols (#95021)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 10 12:29:07 PDT 2024
Author: aengelke
Date: 2024-06-10T21:29:03+02:00
New Revision: 43229977fe0f74bcdfeda20e478065a2072a1846
URL: https://github.com/llvm/llvm-project/commit/43229977fe0f74bcdfeda20e478065a2072a1846
DIFF: https://github.com/llvm/llvm-project/commit/43229977fe0f74bcdfeda20e478065a2072a1846.diff
LOG: [MC] Don't evaluate name of unnamed symbols (#95021)
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.
Added:
Modified:
llvm/include/llvm/MC/MCContext.h
llvm/lib/MC/MCContext.cpp
Removed:
################################################################################
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<void(SMDiagnostic &, const SourceMgr *)>);
MCSymbol *createSymbolImpl(const StringMapEntry<bool> *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<bool> *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);
More information about the llvm-commits
mailing list