set the temporary bit on MCSymbols correctly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98124 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-03-10 02:25:11 +00:00
parent 2d0a91cd6c
commit 98cdab53c3
17 changed files with 87 additions and 53 deletions

View File

@ -127,6 +127,10 @@ public:
static const MCSymbolRefExpr *Create(const MCSymbol *Symbol, MCContext &Ctx);
static const MCSymbolRefExpr *Create(StringRef Name, MCContext &Ctx);
/// CreateTemp - Create a reference to an assembler temporary label with the
/// specified name.
static const MCSymbolRefExpr *CreateTemp(StringRef Name, MCContext &Ctx);
/// @}
/// @name Accessors

View File

@ -911,8 +911,8 @@ void AsmPrinter::EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo,
// Otherwise, emit with .set (aka assignment).
MCSymbol *SetLabel =
OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) + "set" +
Twine(SetCounter++));
OutContext.GetOrCreateTemporarySymbol(Twine(MAI->getPrivateGlobalPrefix()) +
"set" + Twine(SetCounter++));
OutStreamer.EmitAssignment(SetLabel, Diff);
OutStreamer.EmitSymbolValue(SetLabel, Size, 0/*AddrSpace*/);
}
@ -1553,15 +1553,15 @@ void AsmPrinter::printKill(const MachineInstr *MI) const {
/// exception handling tables.
void AsmPrinter::printLabelInst(const MachineInstr *MI) const {
MCSymbol *Sym =
OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) +
OutContext.GetOrCreateTemporarySymbol(Twine(MAI->getPrivateGlobalPrefix()) +
"label" + Twine(MI->getOperand(0).getImm()));
OutStreamer.EmitLabel(Sym);
}
void AsmPrinter::printLabel(unsigned Id) const {
MCSymbol *Sym =
OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) +
"label" + Twine(Id));
OutContext.GetOrCreateTemporarySymbol(Twine(MAI->getPrivateGlobalPrefix()) +
"label" + Twine(Id));
OutStreamer.EmitLabel(Sym);
}
@ -1603,15 +1603,14 @@ MCSymbol *AsmPrinter::GetBlockAddressSymbol(const Function *F,
"_" + FnName.str() + "_" + BB->getName(),
Mangler::Private);
return OutContext.GetOrCreateSymbol(NameResult.str());
return OutContext.GetOrCreateTemporarySymbol(NameResult.str());
}
/// GetCPISymbol - Return the symbol for the specified constant pool entry.
MCSymbol *AsmPrinter::GetCPISymbol(unsigned CPID) const {
SmallString<60> Name;
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "CPI"
<< getFunctionNumber() << '_' << CPID;
return OutContext.GetOrCreateSymbol(Name.str());
return OutContext.GetOrCreateTemporarySymbol
(Twine(MAI->getPrivateGlobalPrefix()) + "CPI" + Twine(getFunctionNumber())
+ "_" + Twine(CPID));
}
/// GetJTISymbol - Return the symbol for the specified jump table entry.
@ -1622,10 +1621,9 @@ 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 {
SmallString<60> Name;
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix()
<< getFunctionNumber() << '_' << UID << "_set_" << MBBID;
return OutContext.GetOrCreateSymbol(Name.str());
return OutContext.GetOrCreateTemporarySymbol
(Twine(MAI->getPrivateGlobalPrefix()) + Twine(getFunctionNumber()) + "_" +
Twine(UID) + "_set_" + Twine(MBBID));
}
/// GetGlobalValueSymbol - Return the MCSymbol for the specified global
@ -1633,7 +1631,10 @@ MCSymbol *AsmPrinter::GetJTSetSymbol(unsigned UID, unsigned MBBID) const {
MCSymbol *AsmPrinter::GetGlobalValueSymbol(const GlobalValue *GV) const {
SmallString<60> NameStr;
Mang->getNameWithPrefix(NameStr, GV, false);
return OutContext.GetOrCreateSymbol(NameStr.str());
if (!GV->hasPrivateLinkage())
return OutContext.GetOrCreateSymbol(NameStr.str());
return OutContext.GetOrCreateTemporarySymbol(NameStr.str());
}
/// GetSymbolWithGlobalValueBase - Return the MCSymbol for a symbol with
@ -1645,7 +1646,9 @@ MCSymbol *AsmPrinter::GetSymbolWithGlobalValueBase(const GlobalValue *GV,
SmallString<60> NameStr;
Mang->getNameWithPrefix(NameStr, GV, ForcePrivate);
NameStr.append(Suffix.begin(), Suffix.end());
return OutContext.GetOrCreateSymbol(NameStr.str());
if (!GV->hasPrivateLinkage() && !ForcePrivate)
return OutContext.GetOrCreateSymbol(NameStr.str());
return OutContext.GetOrCreateTemporarySymbol(NameStr.str());
}
/// GetExternalSymbolSymbol - Return the MCSymbol for the specified

View File

@ -60,7 +60,7 @@ const MCExpr *DwarfException::CreateLabelDiff(const MCExpr *ExprRef,
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix()
<< LabelName << Asm->getFunctionNumber()
<< "_" << Index;
MCSymbol *DotSym = Asm->OutContext.GetOrCreateSymbol(Name.str());
MCSymbol *DotSym = Asm->OutContext.GetOrCreateTemporarySymbol(Name.str());
Asm->OutStreamer.EmitLabel(DotSym);
return MCBinaryExpr::CreateSub(ExprRef,

View File

@ -45,15 +45,15 @@ 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.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix())
+ Twine(Name) + Twine(ID));
return Asm->OutContext.GetOrCreateTemporarySymbol
(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.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix())
+ Name);
return Asm->OutContext.GetOrCreateTemporarySymbol
(Twine(MAI->getPrivateGlobalPrefix()) + Name);
}

View File

@ -42,12 +42,11 @@ MachineBasicBlock::~MachineBasicBlock() {
/// getSymbol - Return the MCSymbol for this basic block.
///
MCSymbol *MachineBasicBlock::getSymbol(MCContext &Ctx) const {
SmallString<60> Name;
const MachineFunction *MF = getParent();
raw_svector_ostream(Name)
<< MF->getTarget().getMCAsmInfo()->getPrivateGlobalPrefix() << "BB"
<< MF->getFunctionNumber() << '_' << getNumber();
return Ctx.GetOrCreateSymbol(Name.str());
const char *Prefix = MF->getTarget().getMCAsmInfo()->getPrivateGlobalPrefix();
return Ctx.GetOrCreateTemporarySymbol(Twine(Prefix) + "BB" +
Twine(MF->getFunctionNumber()) + "_" +
Twine(getNumber()));
}

View File

@ -464,7 +464,9 @@ MCSymbol *MachineFunction::getJTISymbol(unsigned JTI, MCContext &Ctx,
SmallString<60> Name;
raw_svector_ostream(Name)
<< Prefix << "JTI" << getFunctionNumber() << '_' << JTI;
return Ctx.GetOrCreateSymbol(Name.str());
if (isLinkerPrivate)
return Ctx.GetOrCreateSymbol(Name.str());
return Ctx.GetOrCreateTemporarySymbol(Name.str());
}

View File

@ -403,12 +403,15 @@ getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
// Add information about the stub reference to ELFMMI so that the stub
// gets emitted by the asmprinter.
MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str());
MCSymbol *Sym = getContext().GetOrCreateTemporarySymbol(Name.str());
MCSymbol *&StubSym = ELFMMI.getGVStubEntry(Sym);
if (StubSym == 0) {
Name.clear();
Mang->getNameWithPrefix(Name, GV, false);
StubSym = getContext().GetOrCreateSymbol(Name.str());
if (GV->hasPrivateLinkage())
StubSym = getContext().GetOrCreateTemporarySymbol(Name.str());
else
StubSym = getContext().GetOrCreateSymbol(Name.str());
}
return TargetLoweringObjectFile::
@ -749,12 +752,15 @@ getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
// Add information about the stub reference to MachOMMI so that the stub
// gets emitted by the asmprinter.
MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str());
MCSymbol *Sym = getContext().GetOrCreateTemporarySymbol(Name.str());
MCSymbol *&StubSym = MachOMMI.getGVStubEntry(Sym);
if (StubSym == 0) {
Name.clear();
Mang->getNameWithPrefix(Name, GV, false);
StubSym = getContext().GetOrCreateSymbol(Name.str());
if (GV->hasPrivateLinkage())
StubSym = getContext().GetOrCreateTemporarySymbol(Name.str());
else
StubSym = getContext().GetOrCreateSymbol(Name.str());
}
return TargetLoweringObjectFile::

View File

@ -133,6 +133,11 @@ const MCSymbolRefExpr *MCSymbolRefExpr::Create(StringRef Name, MCContext &Ctx) {
return Create(Ctx.GetOrCreateSymbol(Name), Ctx);
}
const MCSymbolRefExpr *MCSymbolRefExpr::CreateTemp(StringRef Name,
MCContext &Ctx) {
return Create(Ctx.GetOrCreateTemporarySymbol(Name), Ctx);
}
void MCTargetExpr::Anchor() {}
/* *** */

View File

@ -849,7 +849,7 @@ GetARMSetPICJumpTableLabel2(unsigned uid, unsigned uid2,
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix()
<< getFunctionNumber() << '_' << uid << '_' << uid2
<< "_set_" << MBB->getNumber();
return OutContext.GetOrCreateSymbol(Name.str());
return OutContext.GetOrCreateTemporarySymbol(Name.str());
}
MCSymbol *ARMAsmPrinter::
@ -857,7 +857,7 @@ GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const {
SmallString<60> Name;
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "JTI"
<< getFunctionNumber() << '_' << uid << '_' << uid2;
return OutContext.GetOrCreateSymbol(Name.str());
return OutContext.GetOrCreateTemporarySymbol(Name.str());
}
void ARMAsmPrinter::printJTBlockOperand(const MachineInstr *MI, int OpNum) {
@ -1192,7 +1192,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.GetOrCreateSymbol(Twine(Prefix)
MCSymbol *Label =OutContext.GetOrCreateTemporarySymbol(Twine(Prefix)
+ "PC" + Twine(getFunctionNumber()) + "_" + Twine(Id));
OutStreamer.EmitLabel(Label);

View File

@ -74,7 +74,7 @@ GetJumpTableSymbol(const MachineOperand &MO) const {
#endif
// Create a symbol for the name.
return Ctx.GetOrCreateSymbol(Name.str());
return Ctx.GetOrCreateTemporarySymbol(Name.str());
}
MCSymbol *ARMMCInstLower::
@ -90,7 +90,7 @@ GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
#endif
// Create a symbol for the name.
return Ctx.GetOrCreateSymbol(Name.str());
return Ctx.GetOrCreateTemporarySymbol(Name.str());
}
MCOperand ARMMCInstLower::

View File

@ -58,7 +58,7 @@ GetJumpTableSymbol(const MachineOperand &MO) const {
}
// Create a symbol for the name.
return Ctx.GetOrCreateSymbol(Name.str());
return Ctx.GetOrCreateTemporarySymbol(Name.str());
}
MCSymbol *MSP430MCInstLower::
@ -74,7 +74,7 @@ GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
}
// Create a symbol for the name.
return Ctx.GetOrCreateSymbol(Name.str());
return Ctx.GetOrCreateTemporarySymbol(Name.str());
}
MCOperand MSP430MCInstLower::

View File

@ -309,8 +309,8 @@ namespace {
const MCSymbol *&TOCEntry = TOC[Sym];
if (TOCEntry == 0)
TOCEntry = OutContext.
GetOrCreateSymbol(StringRef(MAI->getPrivateGlobalPrefix()) + "C" +
Twine(LabelID++));
GetOrCreateTemporarySymbol(StringRef(MAI->getPrivateGlobalPrefix()) +
"C" + Twine(LabelID++));
O << *TOCEntry << "@toc";
}
@ -672,14 +672,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.GetOrCreateSymbol(TmpStr.str());
return Ctx.GetOrCreateTemporarySymbol(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.GetOrCreateSymbol(TmpStr.str());
return Ctx.GetOrCreateTemporarySymbol(TmpStr.str());
}
void PPCDarwinAsmPrinter::

View File

@ -295,7 +295,12 @@ getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
// FIXME: Use GetGlobalValueSymbol.
SmallString<128> Name;
Mang->getNameWithPrefix(Name, GV, false);
const MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str());
const MCSymbol *Sym;
if (GV->hasPrivateLinkage())
Sym = getContext().GetOrCreateTemporarySymbol(Name.str());
else
Sym = getContext().GetOrCreateSymbol(Name.str());
return getSymbolForDwarfReference(Sym, MMI, Encoding);
}

View File

@ -56,7 +56,11 @@ void X86AsmPrinter::PrintPICBaseSymbol() const {
MCSymbol *X86AsmPrinter::GetGlobalValueSymbol(const GlobalValue *GV) const {
SmallString<60> NameStr;
Mang->getNameWithPrefix(NameStr, GV, false);
MCSymbol *Symb = OutContext.GetOrCreateSymbol(NameStr.str());
MCSymbol *Symb;
if (GV->hasPrivateLinkage())
Symb = OutContext.GetOrCreateTemporarySymbol(NameStr.str());
else
Symb = OutContext.GetOrCreateSymbol(NameStr.str());
if (Subtarget->isTargetCygMing()) {
X86COFFMachineModuleInfo &COFFMMI =

View File

@ -89,7 +89,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.GetOrCreateSymbol(Name.str());
MCSymbol *Sym = Ctx.GetOrCreateTemporarySymbol(Name.str());
MCSymbol *&StubSym = getMachOMMI().getGVStubEntry(Sym);
if (StubSym == 0) {
@ -100,7 +100,7 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
}
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: {
Name += "$non_lazy_ptr";
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
MCSymbol *Sym = Ctx.GetOrCreateTemporarySymbol(Name.str());
MCSymbol *&StubSym = getMachOMMI().getHiddenGVStubEntry(Sym);
if (StubSym == 0) {
assert(MO.isGlobal() && "Extern symbol not handled yet");
@ -110,7 +110,7 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
}
case X86II::MO_DARWIN_STUB: {
Name += "$stub";
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
MCSymbol *Sym = Ctx.GetOrCreateTemporarySymbol(Name.str());
MCSymbol *&StubSym = getMachOMMI().getFnStubEntry(Sym);
if (StubSym)
return Sym;
@ -119,7 +119,7 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
StubSym = AsmPrinter.GetGlobalValueSymbol(MO.getGlobal());
} else {
Name.erase(Name.end()-5, Name.end());
StubSym = Ctx.GetOrCreateSymbol(Name.str());
StubSym = Ctx.GetOrCreateTemporarySymbol(Name.str());
}
return Sym;
}
@ -394,7 +394,8 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
// However, we can't generate a ".", so just emit a new label here and refer
// to it. We know that this operand flag occurs at most once per function.
const char *Prefix = MAI->getPrivateGlobalPrefix();
MCSymbol *DotSym = OutContext.GetOrCreateSymbol(Twine(Prefix)+"picbaseref"+
MCSymbol *DotSym = OutContext.GetOrCreateTemporarySymbol(Twine(Prefix)+
"picbaseref" +
Twine(getFunctionNumber()));
OutStreamer.EmitLabel(DotSym);

View File

@ -1105,8 +1105,8 @@ MCSymbol *
X86TargetLowering::getPICBaseSymbol(const MachineFunction *MF,
MCContext &Ctx) const {
const MCAsmInfo &MAI = *getTargetMachine().getMCAsmInfo();
return Ctx.GetOrCreateSymbol(Twine(MAI.getPrivateGlobalPrefix())+
Twine(MF->getFunctionNumber())+"$pb");
return Ctx.GetOrCreateTemporarySymbol(Twine(MAI.getPrivateGlobalPrefix())+
Twine(MF->getFunctionNumber())+"$pb");
}

View File

@ -20,14 +20,19 @@ using namespace dwarf;
const MCExpr *X8664_MachoTargetObjectFile::
getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
MachineModuleInfo *MMI, unsigned Encoding) const {
MachineModuleInfo *MMI,
unsigned Encoding) const {
// On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which
// is an indirect pc-relative reference.
if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) {
SmallString<128> Name;
Mang->getNameWithPrefix(Name, GV, false);
const MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
const MCSymbol *Sym;
if (GV->hasPrivateLinkage())
Sym = getContext().GetOrCreateTemporarySymbol(Name);
else
Sym = getContext().GetOrCreateSymbol(Name);
const MCExpr *Res =
X86MCTargetExpr::Create(Sym, X86MCTargetExpr::GOTPCREL, getContext());
const MCExpr *Four = MCConstantExpr::Create(4, getContext());