llvm.org GIT mirror llvm / 98cdab5
set the temporary bit on MCSymbols correctly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98124 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
17 changed file(s) with 87 addition(s) and 53 deletion(s). Raw diff Collapse all Expand all
126126
127127 static const MCSymbolRefExpr *Create(const MCSymbol *Symbol, MCContext &Ctx);
128128 static const MCSymbolRefExpr *Create(StringRef Name, MCContext &Ctx);
129
130 /// CreateTemp - Create a reference to an assembler temporary label with the
131 /// specified name.
132 static const MCSymbolRefExpr *CreateTemp(StringRef Name, MCContext &Ctx);
129133
130134 /// @}
131135 /// @name Accessors
910910
911911 // Otherwise, emit with .set (aka assignment).
912912 MCSymbol *SetLabel =
913 OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) + "set" +
914 Twine(SetCounter++));
913 OutContext.GetOrCreateTemporarySymbol(Twine(MAI->getPrivateGlobalPrefix()) +
914 "set" + Twine(SetCounter++));
915915 OutStreamer.EmitAssignment(SetLabel, Diff);
916916 OutStreamer.EmitSymbolValue(SetLabel, Size, 0/*AddrSpace*/);
917917 }
15521552 /// exception handling tables.
15531553 void AsmPrinter::printLabelInst(const MachineInstr *MI) const {
15541554 MCSymbol *Sym =
1555 OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) +
1555 OutContext.GetOrCreateTemporarySymbol(Twine(MAI->getPrivateGlobalPrefix()) +
15561556 "label" + Twine(MI->getOperand(0).getImm()));
15571557 OutStreamer.EmitLabel(Sym);
15581558 }
15591559
15601560 void AsmPrinter::printLabel(unsigned Id) const {
15611561 MCSymbol *Sym =
1562 OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) +
1563 "label" + Twine(Id));
1562 OutContext.GetOrCreateTemporarySymbol(Twine(MAI->getPrivateGlobalPrefix()) +
1563 "label" + Twine(Id));
15641564 OutStreamer.EmitLabel(Sym);
15651565 }
15661566
16021602 "_" + FnName.str() + "_" + BB->getName(),
16031603 Mangler::Private);
16041604
1605 return OutContext.GetOrCreateSymbol(NameResult.str());
1605 return OutContext.GetOrCreateTemporarySymbol(NameResult.str());
16061606 }
16071607
16081608 /// GetCPISymbol - Return the symbol for the specified constant pool entry.
16091609 MCSymbol *AsmPrinter::GetCPISymbol(unsigned CPID) const {
1610 SmallString<60> Name;
1611 raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "CPI"
1612 << getFunctionNumber() << '_' << CPID;
1613 return OutContext.GetOrCreateSymbol(Name.str());
1610 return OutContext.GetOrCreateTemporarySymbol
1611 (Twine(MAI->getPrivateGlobalPrefix()) + "CPI" + Twine(getFunctionNumber())
1612 + "_" + Twine(CPID));
16141613 }
16151614
16161615 /// GetJTISymbol - Return the symbol for the specified jump table entry.
16211620 /// GetJTSetSymbol - Return the symbol for the specified jump table .set
16221621 /// FIXME: privatize to AsmPrinter.
16231622 MCSymbol *AsmPrinter::GetJTSetSymbol(unsigned UID, unsigned MBBID) const {
1624 SmallString<60> Name;
1625 raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix()
1626 << getFunctionNumber() << '_' << UID << "_set_" << MBBID;
1627 return OutContext.GetOrCreateSymbol(Name.str());
1623 return OutContext.GetOrCreateTemporarySymbol
1624 (Twine(MAI->getPrivateGlobalPrefix()) + Twine(getFunctionNumber()) + "_" +
1625 Twine(UID) + "_set_" + Twine(MBBID));
16281626 }
16291627
16301628 /// GetGlobalValueSymbol - Return the MCSymbol for the specified global
16321630 MCSymbol *AsmPrinter::GetGlobalValueSymbol(const GlobalValue *GV) const {
16331631 SmallString<60> NameStr;
16341632 Mang->getNameWithPrefix(NameStr, GV, false);
1635 return OutContext.GetOrCreateSymbol(NameStr.str());
1633
1634 if (!GV->hasPrivateLinkage())
1635 return OutContext.GetOrCreateSymbol(NameStr.str());
1636 return OutContext.GetOrCreateTemporarySymbol(NameStr.str());
16361637 }
16371638
16381639 /// GetSymbolWithGlobalValueBase - Return the MCSymbol for a symbol with
16441645 SmallString<60> NameStr;
16451646 Mang->getNameWithPrefix(NameStr, GV, ForcePrivate);
16461647 NameStr.append(Suffix.begin(), Suffix.end());
1647 return OutContext.GetOrCreateSymbol(NameStr.str());
1648 if (!GV->hasPrivateLinkage() && !ForcePrivate)
1649 return OutContext.GetOrCreateSymbol(NameStr.str());
1650 return OutContext.GetOrCreateTemporarySymbol(NameStr.str());
16481651 }
16491652
16501653 /// GetExternalSymbolSymbol - Return the MCSymbol for the specified
5959 raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix()
6060 << LabelName << Asm->getFunctionNumber()
6161 << "_" << Index;
62 MCSymbol *DotSym = Asm->OutContext.GetOrCreateSymbol(Name.str());
62 MCSymbol *DotSym = Asm->OutContext.GetOrCreateTemporarySymbol(Name.str());
6363 Asm->OutStreamer.EmitLabel(DotSym);
6464
6565 return MCBinaryExpr::CreateSub(ExprRef,
4444
4545 //assert(ID && "Should use getTempLabel if no ID");
4646 if (ID == 0) return getTempLabel(Name);
47 return Asm->OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix())
48 + Twine(Name) + Twine(ID));
47 return Asm->OutContext.GetOrCreateTemporarySymbol
48 (Twine(MAI->getPrivateGlobalPrefix()) + Twine(Name) + Twine(ID));
4949 }
5050
5151 /// getTempLabel - Return the MCSymbol corresponding to the assembler temporary
5252 /// label with the specified name.
5353 MCSymbol *DwarfPrinter::getTempLabel(const char *Name) const {
54 return Asm->OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix())
55 + Name);
54 return Asm->OutContext.GetOrCreateTemporarySymbol
55 (Twine(MAI->getPrivateGlobalPrefix()) + Name);
5656 }
5757
5858
4141 /// getSymbol - Return the MCSymbol for this basic block.
4242 ///
4343 MCSymbol *MachineBasicBlock::getSymbol(MCContext &Ctx) const {
44 SmallString<60> Name;
4544 const MachineFunction *MF = getParent();
46 raw_svector_ostream(Name)
47 << MF->getTarget().getMCAsmInfo()->getPrivateGlobalPrefix() << "BB"
48 << MF->getFunctionNumber() << '_' << getNumber();
49 return Ctx.GetOrCreateSymbol(Name.str());
45 const char *Prefix = MF->getTarget().getMCAsmInfo()->getPrivateGlobalPrefix();
46 return Ctx.GetOrCreateTemporarySymbol(Twine(Prefix) + "BB" +
47 Twine(MF->getFunctionNumber()) + "_" +
48 Twine(getNumber()));
5049 }
5150
5251
463463 SmallString<60> Name;
464464 raw_svector_ostream(Name)
465465 << Prefix << "JTI" << getFunctionNumber() << '_' << JTI;
466 return Ctx.GetOrCreateSymbol(Name.str());
466 if (isLinkerPrivate)
467 return Ctx.GetOrCreateSymbol(Name.str());
468 return Ctx.GetOrCreateTemporarySymbol(Name.str());
467469 }
468470
469471
402402
403403 // Add information about the stub reference to ELFMMI so that the stub
404404 // gets emitted by the asmprinter.
405 MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str());
405 MCSymbol *Sym = getContext().GetOrCreateTemporarySymbol(Name.str());
406406 MCSymbol *&StubSym = ELFMMI.getGVStubEntry(Sym);
407407 if (StubSym == 0) {
408408 Name.clear();
409409 Mang->getNameWithPrefix(Name, GV, false);
410 StubSym = getContext().GetOrCreateSymbol(Name.str());
410 if (GV->hasPrivateLinkage())
411 StubSym = getContext().GetOrCreateTemporarySymbol(Name.str());
412 else
413 StubSym = getContext().GetOrCreateSymbol(Name.str());
411414 }
412415
413416 return TargetLoweringObjectFile::
748751
749752 // Add information about the stub reference to MachOMMI so that the stub
750753 // gets emitted by the asmprinter.
751 MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str());
754 MCSymbol *Sym = getContext().GetOrCreateTemporarySymbol(Name.str());
752755 MCSymbol *&StubSym = MachOMMI.getGVStubEntry(Sym);
753756 if (StubSym == 0) {
754757 Name.clear();
755758 Mang->getNameWithPrefix(Name, GV, false);
756 StubSym = getContext().GetOrCreateSymbol(Name.str());
759 if (GV->hasPrivateLinkage())
760 StubSym = getContext().GetOrCreateTemporarySymbol(Name.str());
761 else
762 StubSym = getContext().GetOrCreateSymbol(Name.str());
757763 }
758764
759765 return TargetLoweringObjectFile::
130130
131131 const MCSymbolRefExpr *MCSymbolRefExpr::Create(StringRef Name, MCContext &Ctx) {
132132 return Create(Ctx.GetOrCreateSymbol(Name), Ctx);
133 }
134
135 const MCSymbolRefExpr *MCSymbolRefExpr::CreateTemp(StringRef Name,
136 MCContext &Ctx) {
137 return Create(Ctx.GetOrCreateTemporarySymbol(Name), Ctx);
133138 }
134139
135140 void MCTargetExpr::Anchor() {}
848848 raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix()
849849 << getFunctionNumber() << '_' << uid << '_' << uid2
850850 << "_set_" << MBB->getNumber();
851 return OutContext.GetOrCreateSymbol(Name.str());
851 return OutContext.GetOrCreateTemporarySymbol(Name.str());
852852 }
853853
854854 MCSymbol *ARMAsmPrinter::
856856 SmallString<60> Name;
857857 raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "JTI"
858858 << getFunctionNumber() << '_' << uid << '_' << uid2;
859 return OutContext.GetOrCreateSymbol(Name.str());
859 return OutContext.GetOrCreateTemporarySymbol(Name.str());
860860 }
861861
862862 void ARMAsmPrinter::printJTBlockOperand(const MachineInstr *MI, int OpNum) {
11911191 // FIXME: MOVE TO SHARED PLACE.
11921192 unsigned Id = (unsigned)MI->getOperand(2).getImm();
11931193 const char *Prefix = MAI->getPrivateGlobalPrefix();
1194 MCSymbol *Label =OutContext.GetOrCreateSymbol(Twine(Prefix)
1194 MCSymbol *Label =OutContext.GetOrCreateTemporarySymbol(Twine(Prefix)
11951195 + "PC" + Twine(getFunctionNumber()) + "_" + Twine(Id));
11961196 OutStreamer.EmitLabel(Label);
11971197
7373 #endif
7474
7575 // Create a symbol for the name.
76 return Ctx.GetOrCreateSymbol(Name.str());
76 return Ctx.GetOrCreateTemporarySymbol(Name.str());
7777 }
7878
7979 MCSymbol *ARMMCInstLower::
8989 #endif
9090
9191 // Create a symbol for the name.
92 return Ctx.GetOrCreateSymbol(Name.str());
92 return Ctx.GetOrCreateTemporarySymbol(Name.str());
9393 }
9494
9595 MCOperand ARMMCInstLower::
5757 }
5858
5959 // Create a symbol for the name.
60 return Ctx.GetOrCreateSymbol(Name.str());
60 return Ctx.GetOrCreateTemporarySymbol(Name.str());
6161 }
6262
6363 MCSymbol *MSP430MCInstLower::
7373 }
7474
7575 // Create a symbol for the name.
76 return Ctx.GetOrCreateSymbol(Name.str());
76 return Ctx.GetOrCreateTemporarySymbol(Name.str());
7777 }
7878
7979 MCOperand MSP430MCInstLower::
308308 const MCSymbol *&TOCEntry = TOC[Sym];
309309 if (TOCEntry == 0)
310310 TOCEntry = OutContext.
311 GetOrCreateSymbol(StringRef(MAI->getPrivateGlobalPrefix()) + "C" +
312 Twine(LabelID++));
311 GetOrCreateTemporarySymbol(StringRef(MAI->getPrivateGlobalPrefix()) +
312 "C" + Twine(LabelID++));
313313
314314 O << *TOCEntry << "@toc";
315315 }
671671 // Remove $stub suffix, add $lazy_ptr.
672672 SmallString<128> TmpStr(Sym->getName().begin(), Sym->getName().end()-5);
673673 TmpStr += "$lazy_ptr";
674 return Ctx.GetOrCreateSymbol(TmpStr.str());
674 return Ctx.GetOrCreateTemporarySymbol(TmpStr.str());
675675 }
676676
677677 static const MCSymbol *GetAnonSym(const MCSymbol *Sym, MCContext &Ctx) {
678678 // Add $tmp suffix to $stub, yielding $stub$tmp.
679679 SmallString<128> TmpStr(Sym->getName().begin(), Sym->getName().end());
680680 TmpStr += "$tmp";
681 return Ctx.GetOrCreateSymbol(TmpStr.str());
681 return Ctx.GetOrCreateTemporarySymbol(TmpStr.str());
682682 }
683683
684684 void PPCDarwinAsmPrinter::
294294 // FIXME: Use GetGlobalValueSymbol.
295295 SmallString<128> Name;
296296 Mang->getNameWithPrefix(Name, GV, false);
297 const MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str());
297 const MCSymbol *Sym;
298
299 if (GV->hasPrivateLinkage())
300 Sym = getContext().GetOrCreateTemporarySymbol(Name.str());
301 else
302 Sym = getContext().GetOrCreateSymbol(Name.str());
298303
299304 return getSymbolForDwarfReference(Sym, MMI, Encoding);
300305 }
5555 MCSymbol *X86AsmPrinter::GetGlobalValueSymbol(const GlobalValue *GV) const {
5656 SmallString<60> NameStr;
5757 Mang->getNameWithPrefix(NameStr, GV, false);
58 MCSymbol *Symb = OutContext.GetOrCreateSymbol(NameStr.str());
58 MCSymbol *Symb;
59 if (GV->hasPrivateLinkage())
60 Symb = OutContext.GetOrCreateTemporarySymbol(NameStr.str());
61 else
62 Symb = OutContext.GetOrCreateSymbol(NameStr.str());
5963
6064 if (Subtarget->isTargetCygMing()) {
6165 X86COFFMachineModuleInfo &COFFMMI =
8888 case X86II::MO_DARWIN_NONLAZY:
8989 case X86II::MO_DARWIN_NONLAZY_PIC_BASE: {
9090 Name += "$non_lazy_ptr";
91 MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
91 MCSymbol *Sym = Ctx.GetOrCreateTemporarySymbol(Name.str());
9292
9393 MCSymbol *&StubSym = getMachOMMI().getGVStubEntry(Sym);
9494 if (StubSym == 0) {
9999 }
100100 case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: {
101101 Name += "$non_lazy_ptr";
102 MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
102 MCSymbol *Sym = Ctx.GetOrCreateTemporarySymbol(Name.str());
103103 MCSymbol *&StubSym = getMachOMMI().getHiddenGVStubEntry(Sym);
104104 if (StubSym == 0) {
105105 assert(MO.isGlobal() && "Extern symbol not handled yet");
109109 }
110110 case X86II::MO_DARWIN_STUB: {
111111 Name += "$stub";
112 MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
112 MCSymbol *Sym = Ctx.GetOrCreateTemporarySymbol(Name.str());
113113 MCSymbol *&StubSym = getMachOMMI().getFnStubEntry(Sym);
114114 if (StubSym)
115115 return Sym;
118118 StubSym = AsmPrinter.GetGlobalValueSymbol(MO.getGlobal());
119119 } else {
120120 Name.erase(Name.end()-5, Name.end());
121 StubSym = Ctx.GetOrCreateSymbol(Name.str());
121 StubSym = Ctx.GetOrCreateTemporarySymbol(Name.str());
122122 }
123123 return Sym;
124124 }
393393 // However, we can't generate a ".", so just emit a new label here and refer
394394 // to it. We know that this operand flag occurs at most once per function.
395395 const char *Prefix = MAI->getPrivateGlobalPrefix();
396 MCSymbol *DotSym = OutContext.GetOrCreateSymbol(Twine(Prefix)+"picbaseref"+
396 MCSymbol *DotSym = OutContext.GetOrCreateTemporarySymbol(Twine(Prefix)+
397 "picbaseref" +
397398 Twine(getFunctionNumber()));
398399 OutStreamer.EmitLabel(DotSym);
399400
11041104 X86TargetLowering::getPICBaseSymbol(const MachineFunction *MF,
11051105 MCContext &Ctx) const {
11061106 const MCAsmInfo &MAI = *getTargetMachine().getMCAsmInfo();
1107 return Ctx.GetOrCreateSymbol(Twine(MAI.getPrivateGlobalPrefix())+
1108 Twine(MF->getFunctionNumber())+"$pb");
1107 return Ctx.GetOrCreateTemporarySymbol(Twine(MAI.getPrivateGlobalPrefix())+
1108 Twine(MF->getFunctionNumber())+"$pb");
11091109 }
11101110
11111111
1919
2020 const MCExpr *X8664_MachoTargetObjectFile::
2121 getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
22 MachineModuleInfo *MMI, unsigned Encoding) const {
22 MachineModuleInfo *MMI,
23 unsigned Encoding) const {
2324
2425 // On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which
2526 // is an indirect pc-relative reference.
2627 if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) {
2728 SmallString<128> Name;
2829 Mang->getNameWithPrefix(Name, GV, false);
29 const MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
30 const MCSymbol *Sym;
31 if (GV->hasPrivateLinkage())
32 Sym = getContext().GetOrCreateTemporarySymbol(Name);
33 else
34 Sym = getContext().GetOrCreateSymbol(Name);
3035 const MCExpr *Res =
3136 X86MCTargetExpr::Create(Sym, X86MCTargetExpr::GOTPCREL, getContext());
3237 const MCExpr *Four = MCConstantExpr::Create(4, getContext());