diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h index 564a6be9e62..1790905a124 100644 --- a/include/llvm/MC/MCContext.h +++ b/include/llvm/MC/MCContext.h @@ -208,7 +208,8 @@ namespace llvm { MCSymbol *createSymbolImpl(const StringMapEntry *Name, bool IsTemporary); - MCSymbol *CreateSymbol(StringRef Name, bool AlwaysAddSuffix); + MCSymbol *createSymbol(StringRef Name, bool AlwaysAddSuffix, + bool IsTemporary); MCSymbol *getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal, unsigned Instance); diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index 8179e6c50ce..79f9bdae463 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -114,7 +114,7 @@ MCSymbol *MCContext::getOrCreateSymbol(const Twine &Name) { MCSymbol *&Sym = Symbols[NameRef]; if (!Sym) - Sym = CreateSymbol(NameRef, false); + Sym = createSymbol(NameRef, false, false); return Sym; } @@ -165,15 +165,17 @@ MCSymbol *MCContext::createSymbolImpl(const StringMapEntry *Name, return new (*this) MCSymbol(false, Name, IsTemporary); } -MCSymbol *MCContext::CreateSymbol(StringRef Name, bool AlwaysAddSuffix) { - // Determine whether this is an assembler temporary or normal label, if used. - bool IsTemporary = false; +MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix, + bool IsTemporary) { + if (IsTemporary && !UseNamesOnTempLabels) + return createSymbolImpl(nullptr, true); + + // Determine whether this is an user writter assembler temporary or normal + // label, if used. + IsTemporary = false; if (AllowTemporaryLabels) IsTemporary = Name.startswith(MAI->getPrivateGlobalPrefix()); - if (IsTemporary && AlwaysAddSuffix && !UseNamesOnTempLabels) - return createSymbolImpl(nullptr, true); - SmallString<128> NewName = Name; bool AddSuffix = AlwaysAddSuffix; unsigned &NextUniqueID = NextID[Name]; @@ -197,13 +199,13 @@ MCSymbol *MCContext::CreateSymbol(StringRef Name, bool AlwaysAddSuffix) { MCSymbol *MCContext::createTempSymbol(const Twine &Name, bool AlwaysAddSuffix) { SmallString<128> NameSV; raw_svector_ostream(NameSV) << MAI->getPrivateGlobalPrefix() << Name; - return CreateSymbol(NameSV, AlwaysAddSuffix); + return createSymbol(NameSV, AlwaysAddSuffix, true); } MCSymbol *MCContext::createLinkerPrivateTempSymbol() { SmallString<128> NameSV; raw_svector_ostream(NameSV) << MAI->getLinkerPrivateGlobalPrefix() << "tmp"; - return CreateSymbol(NameSV, true); + return createSymbol(NameSV, true, false); } MCSymbol *MCContext::createTempSymbol() {