Skip to content

Commit 4322997

Browse files
authored
[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.
1 parent 23a33a7 commit 4322997

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

llvm/include/llvm/MC/MCContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ class MCContext {
371371
std::function<void(SMDiagnostic &, const SourceMgr *)>);
372372

373373
MCSymbol *createSymbolImpl(const StringMapEntry<bool> *Name,
374-
bool CanBeUnnamed);
374+
bool IsTemporary);
375375
MCSymbol *createSymbol(StringRef Name, bool AlwaysAddSuffix,
376376
bool IsTemporary);
377377

llvm/lib/MC/MCContext.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,9 @@ MCSymbol *MCContext::createSymbolImpl(const StringMapEntry<bool> *Name,
264264
}
265265

266266
MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix,
267-
bool CanBeUnnamed) {
268-
if (CanBeUnnamed && !UseNamesOnTempLabels)
269-
return createSymbolImpl(nullptr, true);
270-
267+
bool IsTemporary) {
271268
// Determine whether this is a user written assembler temporary or normal
272269
// label, if used.
273-
bool IsTemporary = CanBeUnnamed;
274270
if (AllowTemporaryLabels && !IsTemporary)
275271
IsTemporary = Name.starts_with(MAI->getPrivateGlobalPrefix());
276272

@@ -298,6 +294,9 @@ MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix,
298294
}
299295

300296
MCSymbol *MCContext::createTempSymbol(const Twine &Name, bool AlwaysAddSuffix) {
297+
if (!UseNamesOnTempLabels)
298+
return createSymbolImpl(nullptr, /*IsTemporary=*/true);
299+
301300
SmallString<128> NameSV;
302301
raw_svector_ostream(NameSV) << MAI->getPrivateGlobalPrefix() << Name;
303302
return createSymbol(NameSV, AlwaysAddSuffix, true);

0 commit comments

Comments
 (0)