[llvm] [MC] Don't evaluate name of unnamed symbols (PR #95021)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 10 11:27:57 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mc
Author: None (aengelke)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/95021.diff
2 Files Affected:
- (modified) llvm/include/llvm/MC/MCContext.h (+1-1)
- (modified) llvm/lib/MC/MCContext.cpp (+4-5)
``````````diff
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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/95021
More information about the llvm-commits
mailing list