mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
Rip out the 'is temporary' nonsense from the MCContext interface to
create symbols. It is extremely error prone and a source of a lot of the remaining integrated assembler bugs on x86-64. This fixes rdar://7807601. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99902 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
87bd191602
commit
9b97a73ded
@ -65,19 +65,8 @@ namespace llvm {
|
||||
/// reference and return it.
|
||||
///
|
||||
/// @param Name - The symbol name, which must be unique across all symbols.
|
||||
MCSymbol *GetOrCreateSymbol(StringRef Name, bool isTemporary = false);
|
||||
MCSymbol *GetOrCreateSymbol(const Twine &Name, bool isTemporary = false);
|
||||
|
||||
/// GetOrCreateTemporarySymbol - Create a new assembler temporary symbol
|
||||
/// with the specified @p Name if it doesn't exist or return the existing
|
||||
/// one if it does.
|
||||
///
|
||||
/// @param Name - The symbol name, for debugging purposes only, temporary
|
||||
/// symbols do not surive assembly.
|
||||
MCSymbol *GetOrCreateTemporarySymbol(StringRef Name) {
|
||||
return GetOrCreateSymbol(Name, true);
|
||||
}
|
||||
MCSymbol *GetOrCreateTemporarySymbol(const Twine &Name);
|
||||
MCSymbol *GetOrCreateSymbol(StringRef Name);
|
||||
MCSymbol *GetOrCreateSymbol(const Twine &Name);
|
||||
|
||||
/// LookupSymbol - Get the symbol for \p Name, or null.
|
||||
MCSymbol *LookupSymbol(StringRef Name) const;
|
||||
|
@ -160,11 +160,6 @@ public:
|
||||
static const MCSymbolRefExpr *Create(StringRef Name, VariantKind Kind,
|
||||
MCContext &Ctx);
|
||||
|
||||
/// CreateTemp - Create a reference to an assembler temporary label with the
|
||||
/// specified name.
|
||||
static const MCSymbolRefExpr *CreateTemp(StringRef Name, VariantKind Kind,
|
||||
MCContext &Ctx);
|
||||
|
||||
/// @}
|
||||
/// @name Accessors
|
||||
/// @{
|
||||
|
@ -922,8 +922,8 @@ void AsmPrinter::EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo,
|
||||
|
||||
// Otherwise, emit with .set (aka assignment).
|
||||
MCSymbol *SetLabel =
|
||||
OutContext.GetOrCreateTemporarySymbol(Twine(MAI->getPrivateGlobalPrefix()) +
|
||||
"set" + Twine(SetCounter++));
|
||||
OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) +
|
||||
"set" + Twine(SetCounter++));
|
||||
OutStreamer.EmitAssignment(SetLabel, Diff);
|
||||
OutStreamer.EmitSymbolValue(SetLabel, Size, 0/*AddrSpace*/);
|
||||
}
|
||||
@ -1599,7 +1599,7 @@ MCSymbol *AsmPrinter::GetBlockAddressSymbol(const BasicBlock *BB) const {
|
||||
|
||||
/// GetCPISymbol - Return the symbol for the specified constant pool entry.
|
||||
MCSymbol *AsmPrinter::GetCPISymbol(unsigned CPID) const {
|
||||
return OutContext.GetOrCreateTemporarySymbol
|
||||
return OutContext.GetOrCreateSymbol
|
||||
(Twine(MAI->getPrivateGlobalPrefix()) + "CPI" + Twine(getFunctionNumber())
|
||||
+ "_" + Twine(CPID));
|
||||
}
|
||||
@ -1612,7 +1612,7 @@ MCSymbol *AsmPrinter::GetJTISymbol(unsigned JTID, bool isLinkerPrivate) const {
|
||||
/// GetJTSetSymbol - Return the symbol for the specified jump table .set
|
||||
/// FIXME: privatize to AsmPrinter.
|
||||
MCSymbol *AsmPrinter::GetJTSetSymbol(unsigned UID, unsigned MBBID) const {
|
||||
return OutContext.GetOrCreateTemporarySymbol
|
||||
return OutContext.GetOrCreateSymbol
|
||||
(Twine(MAI->getPrivateGlobalPrefix()) + Twine(getFunctionNumber()) + "_" +
|
||||
Twine(UID) + "_set_" + Twine(MBBID));
|
||||
}
|
||||
@ -1626,9 +1626,7 @@ MCSymbol *AsmPrinter::GetSymbolWithGlobalValueBase(const GlobalValue *GV,
|
||||
SmallString<60> NameStr;
|
||||
Mang->getNameWithPrefix(NameStr, GV, ForcePrivate);
|
||||
NameStr.append(Suffix.begin(), Suffix.end());
|
||||
if (!GV->hasPrivateLinkage() && !ForcePrivate)
|
||||
return OutContext.GetOrCreateSymbol(NameStr.str());
|
||||
return OutContext.GetOrCreateTemporarySymbol(NameStr.str());
|
||||
return OutContext.GetOrCreateSymbol(NameStr.str());
|
||||
}
|
||||
|
||||
/// GetExternalSymbolSymbol - Return the MCSymbol for the specified
|
||||
|
@ -45,14 +45,14 @@ MCSymbol *DwarfPrinter::getDWLabel(const char *Name, unsigned ID) const {
|
||||
|
||||
//assert(ID && "Should use getTempLabel if no ID");
|
||||
if (ID == 0) return getTempLabel(Name);
|
||||
return Asm->OutContext.GetOrCreateTemporarySymbol
|
||||
return Asm->OutContext.GetOrCreateSymbol
|
||||
(Twine(MAI->getPrivateGlobalPrefix()) + Twine(Name) + Twine(ID));
|
||||
}
|
||||
|
||||
/// getTempLabel - Return the MCSymbol corresponding to the assembler temporary
|
||||
/// label with the specified name.
|
||||
MCSymbol *DwarfPrinter::getTempLabel(const char *Name) const {
|
||||
return Asm->OutContext.GetOrCreateTemporarySymbol
|
||||
return Asm->OutContext.GetOrCreateSymbol
|
||||
(Twine(MAI->getPrivateGlobalPrefix()) + Name);
|
||||
}
|
||||
|
||||
|
@ -45,9 +45,9 @@ MCSymbol *MachineBasicBlock::getSymbol() const {
|
||||
const MachineFunction *MF = getParent();
|
||||
MCContext &Ctx = MF->getContext();
|
||||
const char *Prefix = Ctx.getAsmInfo().getPrivateGlobalPrefix();
|
||||
return Ctx.GetOrCreateTemporarySymbol(Twine(Prefix) + "BB" +
|
||||
Twine(MF->getFunctionNumber()) + "_" +
|
||||
Twine(getNumber()));
|
||||
return Ctx.GetOrCreateSymbol(Twine(Prefix) + "BB" +
|
||||
Twine(MF->getFunctionNumber()) + "_" +
|
||||
Twine(getNumber()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -460,9 +460,7 @@ MCSymbol *MachineFunction::getJTISymbol(unsigned JTI, MCContext &Ctx,
|
||||
SmallString<60> Name;
|
||||
raw_svector_ostream(Name)
|
||||
<< Prefix << "JTI" << getFunctionNumber() << '_' << JTI;
|
||||
if (isLinkerPrivate)
|
||||
return Ctx.GetOrCreateSymbol(Name.str());
|
||||
return Ctx.GetOrCreateTemporarySymbol(Name.str());
|
||||
return Ctx.GetOrCreateSymbol(Name.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -406,7 +406,7 @@ getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||
|
||||
// Add information about the stub reference to ELFMMI so that the stub
|
||||
// gets emitted by the asmprinter.
|
||||
MCSymbol *SSym = getContext().GetOrCreateTemporarySymbol(Name.str());
|
||||
MCSymbol *SSym = getContext().GetOrCreateSymbol(Name.str());
|
||||
MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
|
||||
if (StubSym.getPointer() == 0) {
|
||||
MCSymbol *Sym = Mang->getSymbol(GV);
|
||||
@ -759,7 +759,7 @@ getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||
|
||||
// Add information about the stub reference to MachOMMI so that the stub
|
||||
// gets emitted by the asmprinter.
|
||||
MCSymbol *SSym = getContext().GetOrCreateTemporarySymbol(Name.str());
|
||||
MCSymbol *SSym = getContext().GetOrCreateSymbol(Name.str());
|
||||
MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym);
|
||||
if (StubSym.getPointer() == 0) {
|
||||
MCSymbol *Sym = Mang->getSymbol(GV);
|
||||
|
@ -23,9 +23,12 @@ MCContext::~MCContext() {
|
||||
// we don't need to free them here.
|
||||
}
|
||||
|
||||
MCSymbol *MCContext::GetOrCreateSymbol(StringRef Name, bool isTemporary) {
|
||||
MCSymbol *MCContext::GetOrCreateSymbol(StringRef Name) {
|
||||
assert(!Name.empty() && "Normal symbols cannot be unnamed!");
|
||||
|
||||
// Determine whether this is an assembler temporary or normal label.
|
||||
bool isTemporary = Name.startswith(MAI.getPrivateGlobalPrefix());
|
||||
|
||||
// Do the lookup and get the entire StringMapEntry. We want access to the
|
||||
// key if we are creating the entry.
|
||||
StringMapEntry<MCSymbol*> &Entry = Symbols.GetOrCreateValue(Name);
|
||||
@ -38,24 +41,17 @@ MCSymbol *MCContext::GetOrCreateSymbol(StringRef Name, bool isTemporary) {
|
||||
return Result;
|
||||
}
|
||||
|
||||
MCSymbol *MCContext::GetOrCreateSymbol(const Twine &Name, bool isTemporary) {
|
||||
MCSymbol *MCContext::GetOrCreateSymbol(const Twine &Name) {
|
||||
SmallString<128> NameSV;
|
||||
Name.toVector(NameSV);
|
||||
return GetOrCreateSymbol(NameSV.str(), isTemporary);
|
||||
return GetOrCreateSymbol(NameSV.str());
|
||||
}
|
||||
|
||||
MCSymbol *MCContext::CreateTempSymbol() {
|
||||
return GetOrCreateTemporarySymbol(Twine(MAI.getPrivateGlobalPrefix()) +
|
||||
"tmp" + Twine(NextUniqueID++));
|
||||
return GetOrCreateSymbol(Twine(MAI.getPrivateGlobalPrefix()) +
|
||||
"tmp" + Twine(NextUniqueID++));
|
||||
}
|
||||
|
||||
MCSymbol *MCContext::GetOrCreateTemporarySymbol(const Twine &Name) {
|
||||
SmallString<128> NameSV;
|
||||
Name.toVector(NameSV);
|
||||
return GetOrCreateTemporarySymbol(NameSV.str());
|
||||
}
|
||||
|
||||
|
||||
MCSymbol *MCContext::LookupSymbol(StringRef Name) const {
|
||||
return Symbols.lookup(Name);
|
||||
}
|
||||
|
@ -154,12 +154,6 @@ const MCSymbolRefExpr *MCSymbolRefExpr::Create(StringRef Name, VariantKind Kind,
|
||||
return Create(Ctx.GetOrCreateSymbol(Name), Kind, Ctx);
|
||||
}
|
||||
|
||||
const MCSymbolRefExpr *MCSymbolRefExpr::CreateTemp(StringRef Name,
|
||||
VariantKind Kind,
|
||||
MCContext &Ctx) {
|
||||
return Create(Ctx.GetOrCreateTemporarySymbol(Name), Kind, Ctx);
|
||||
}
|
||||
|
||||
StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) {
|
||||
switch (Kind) {
|
||||
default:
|
||||
|
@ -238,9 +238,7 @@ bool AsmParser::ParseParenExpr(const MCExpr *&Res, SMLoc &EndLoc) {
|
||||
}
|
||||
|
||||
MCSymbol *AsmParser::CreateSymbol(StringRef Name) {
|
||||
// If the label starts with L it is an assembler temporary label.
|
||||
if (Name.startswith("L"))
|
||||
return Ctx.GetOrCreateTemporarySymbol(Name);
|
||||
// FIXME: Inline into callers.
|
||||
return Ctx.GetOrCreateSymbol(Name);
|
||||
}
|
||||
|
||||
|
@ -841,7 +841,7 @@ GetARMSetPICJumpTableLabel2(unsigned uid, unsigned uid2,
|
||||
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix()
|
||||
<< getFunctionNumber() << '_' << uid << '_' << uid2
|
||||
<< "_set_" << MBB->getNumber();
|
||||
return OutContext.GetOrCreateTemporarySymbol(Name.str());
|
||||
return OutContext.GetOrCreateSymbol(Name.str());
|
||||
}
|
||||
|
||||
MCSymbol *ARMAsmPrinter::
|
||||
@ -849,7 +849,7 @@ GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const {
|
||||
SmallString<60> Name;
|
||||
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "JTI"
|
||||
<< getFunctionNumber() << '_' << uid << '_' << uid2;
|
||||
return OutContext.GetOrCreateTemporarySymbol(Name.str());
|
||||
return OutContext.GetOrCreateSymbol(Name.str());
|
||||
}
|
||||
|
||||
void ARMAsmPrinter::printJTBlockOperand(const MachineInstr *MI, int OpNum) {
|
||||
@ -1186,7 +1186,7 @@ void ARMAsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI) {
|
||||
// FIXME: MOVE TO SHARED PLACE.
|
||||
unsigned Id = (unsigned)MI->getOperand(2).getImm();
|
||||
const char *Prefix = MAI->getPrivateGlobalPrefix();
|
||||
MCSymbol *Label =OutContext.GetOrCreateTemporarySymbol(Twine(Prefix)
|
||||
MCSymbol *Label =OutContext.GetOrCreateSymbol(Twine(Prefix)
|
||||
+ "PC" + Twine(getFunctionNumber()) + "_" + Twine(Id));
|
||||
OutStreamer.EmitLabel(Label);
|
||||
|
||||
|
@ -75,7 +75,7 @@ GetJumpTableSymbol(const MachineOperand &MO) const {
|
||||
#endif
|
||||
|
||||
// Create a symbol for the name.
|
||||
return Ctx.GetOrCreateTemporarySymbol(Name.str());
|
||||
return Ctx.GetOrCreateSymbol(Name.str());
|
||||
}
|
||||
|
||||
MCSymbol *ARMMCInstLower::
|
||||
@ -91,7 +91,7 @@ GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
|
||||
#endif
|
||||
|
||||
// Create a symbol for the name.
|
||||
return Ctx.GetOrCreateTemporarySymbol(Name.str());
|
||||
return Ctx.GetOrCreateSymbol(Name.str());
|
||||
}
|
||||
|
||||
MCOperand ARMMCInstLower::
|
||||
|
@ -59,7 +59,7 @@ GetJumpTableSymbol(const MachineOperand &MO) const {
|
||||
}
|
||||
|
||||
// Create a symbol for the name.
|
||||
return Ctx.GetOrCreateTemporarySymbol(Name.str());
|
||||
return Ctx.GetOrCreateSymbol(Name.str());
|
||||
}
|
||||
|
||||
MCSymbol *MSP430MCInstLower::
|
||||
@ -75,7 +75,7 @@ GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
|
||||
}
|
||||
|
||||
// Create a symbol for the name.
|
||||
return Ctx.GetOrCreateTemporarySymbol(Name.str());
|
||||
return Ctx.GetOrCreateSymbol(Name.str());
|
||||
}
|
||||
|
||||
MCOperand MSP430MCInstLower::
|
||||
|
@ -235,10 +235,7 @@ std::string Mangler::getNameWithPrefix(const GlobalValue *GV,
|
||||
MCSymbol *Mangler::getSymbol(const GlobalValue *GV) {
|
||||
SmallString<60> NameStr;
|
||||
getNameWithPrefix(NameStr, GV, false);
|
||||
if (!GV->hasPrivateLinkage())
|
||||
return Context.GetOrCreateSymbol(NameStr.str());
|
||||
|
||||
return Context.GetOrCreateTemporarySymbol(NameStr.str());
|
||||
return Context.GetOrCreateSymbol(NameStr.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -309,8 +309,8 @@ namespace {
|
||||
const MCSymbol *&TOCEntry = TOC[Sym];
|
||||
if (TOCEntry == 0)
|
||||
TOCEntry = OutContext.
|
||||
GetOrCreateTemporarySymbol(StringRef(MAI->getPrivateGlobalPrefix()) +
|
||||
"C" + Twine(LabelID++));
|
||||
GetOrCreateSymbol(StringRef(MAI->getPrivateGlobalPrefix()) +
|
||||
"C" + Twine(LabelID++));
|
||||
|
||||
O << *TOCEntry << "@toc";
|
||||
}
|
||||
@ -674,14 +674,14 @@ static const MCSymbol *GetLazyPtr(const MCSymbol *Sym, MCContext &Ctx) {
|
||||
// Remove $stub suffix, add $lazy_ptr.
|
||||
SmallString<128> TmpStr(Sym->getName().begin(), Sym->getName().end()-5);
|
||||
TmpStr += "$lazy_ptr";
|
||||
return Ctx.GetOrCreateTemporarySymbol(TmpStr.str());
|
||||
return Ctx.GetOrCreateSymbol(TmpStr.str());
|
||||
}
|
||||
|
||||
static const MCSymbol *GetAnonSym(const MCSymbol *Sym, MCContext &Ctx) {
|
||||
// Add $tmp suffix to $stub, yielding $stub$tmp.
|
||||
SmallString<128> TmpStr(Sym->getName().begin(), Sym->getName().end());
|
||||
TmpStr += "$tmp";
|
||||
return Ctx.GetOrCreateTemporarySymbol(TmpStr.str());
|
||||
return Ctx.GetOrCreateSymbol(TmpStr.str());
|
||||
}
|
||||
|
||||
void PPCDarwinAsmPrinter::
|
||||
|
@ -83,7 +83,7 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
|
||||
case X86II::MO_DARWIN_NONLAZY:
|
||||
case X86II::MO_DARWIN_NONLAZY_PIC_BASE: {
|
||||
Name += "$non_lazy_ptr";
|
||||
MCSymbol *Sym = Ctx.GetOrCreateTemporarySymbol(Name.str());
|
||||
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
|
||||
|
||||
MachineModuleInfoImpl::StubValueTy &StubSym =
|
||||
getMachOMMI().getGVStubEntry(Sym);
|
||||
@ -98,7 +98,7 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
|
||||
}
|
||||
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: {
|
||||
Name += "$non_lazy_ptr";
|
||||
MCSymbol *Sym = Ctx.GetOrCreateTemporarySymbol(Name.str());
|
||||
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
|
||||
MachineModuleInfoImpl::StubValueTy &StubSym =
|
||||
getMachOMMI().getHiddenGVStubEntry(Sym);
|
||||
if (StubSym.getPointer() == 0) {
|
||||
@ -112,7 +112,7 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
|
||||
}
|
||||
case X86II::MO_DARWIN_STUB: {
|
||||
Name += "$stub";
|
||||
MCSymbol *Sym = Ctx.GetOrCreateTemporarySymbol(Name.str());
|
||||
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
|
||||
MachineModuleInfoImpl::StubValueTy &StubSym =
|
||||
getMachOMMI().getFnStubEntry(Sym);
|
||||
if (StubSym.getPointer())
|
||||
@ -127,7 +127,7 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
|
||||
Name.erase(Name.end()-5, Name.end());
|
||||
StubSym =
|
||||
MachineModuleInfoImpl::
|
||||
StubValueTy(Ctx.GetOrCreateTemporarySymbol(Name.str()), false);
|
||||
StubValueTy(Ctx.GetOrCreateSymbol(Name.str()), false);
|
||||
}
|
||||
return Sym;
|
||||
}
|
||||
|
@ -1112,8 +1112,8 @@ MCSymbol *
|
||||
X86TargetLowering::getPICBaseSymbol(const MachineFunction *MF,
|
||||
MCContext &Ctx) const {
|
||||
const MCAsmInfo &MAI = *getTargetMachine().getMCAsmInfo();
|
||||
return Ctx.GetOrCreateTemporarySymbol(Twine(MAI.getPrivateGlobalPrefix())+
|
||||
Twine(MF->getFunctionNumber())+"$pb");
|
||||
return Ctx.GetOrCreateSymbol(Twine(MAI.getPrivateGlobalPrefix())+
|
||||
Twine(MF->getFunctionNumber())+"$pb");
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user