move gettemplabel and getdwlabel to AsmPrinter and rename

them for consistency.

llvm-svn: 100345
This commit is contained in:
Chris Lattner 2010-04-04 19:25:43 +00:00
parent 9efd118938
commit a179b52361
6 changed files with 178 additions and 160 deletions

View File

@ -190,6 +190,36 @@ namespace llvm {
/// do nothing and return false.
bool EmitSpecialLLVMGlobal(const GlobalVariable *GV);
/// EmitAlignment - Emit an alignment directive to the specified power of
/// two boundary. For example, if you pass in 3 here, you will get an 8
/// byte alignment. If a global value is specified, and if that global has
/// an explicit alignment requested, it will unconditionally override the
/// alignment request. However, if ForcedAlignBits is specified, this value
/// has final say: the ultimate alignment will be the max of ForcedAlignBits
/// and the alignment computed with NumBits and the global. If UseFillExpr
/// is true, it also emits an optional second value FillValue which the
/// assembler uses to fill gaps to match alignment for text sections if the
/// has specified a non-zero fill value.
///
/// The algorithm is:
/// Align = NumBits;
/// if (GV && GV->hasalignment) Align = GV->getalignment();
/// Align = std::max(Align, ForcedAlignBits);
///
void EmitAlignment(unsigned NumBits, const GlobalValue *GV = 0,
unsigned ForcedAlignBits = 0,
bool UseFillExpr = true) const;
/// EmitBasicBlockStart - This method prints the label for the specified
/// MachineBasicBlock, an alignment (if present) and a comment describing
/// it if appropriate.
void EmitBasicBlockStart(const MachineBasicBlock *MBB) const;
/// EmitGlobalConstant - Print a general LLVM constant to the .s file.
void EmitGlobalConstant(const Constant *CV, unsigned AddrSpace = 0);
//===------------------------------------------------------------------===//
// Overridable Hooks
//===------------------------------------------------------------------===//
@ -229,30 +259,19 @@ namespace llvm {
isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const;
//===------------------------------------------------------------------===//
// Lowering Routines.
// Symbol Lowering Routines.
//===------------------------------------------------------------------===//
public:
/// EmitAlignment - Emit an alignment directive to the specified power of
/// two boundary. For example, if you pass in 3 here, you will get an 8
/// byte alignment. If a global value is specified, and if that global has
/// an explicit alignment requested, it will unconditionally override the
/// alignment request. However, if ForcedAlignBits is specified, this value
/// has final say: the ultimate alignment will be the max of ForcedAlignBits
/// and the alignment computed with NumBits and the global. If UseFillExpr
/// is true, it also emits an optional second value FillValue which the
/// assembler uses to fill gaps to match alignment for text sections if the
/// has specified a non-zero fill value.
///
/// The algorithm is:
/// Align = NumBits;
/// if (GV && GV->hasalignment) Align = GV->getalignment();
/// Align = std::max(Align, ForcedAlignBits);
///
void EmitAlignment(unsigned NumBits, const GlobalValue *GV = 0,
unsigned ForcedAlignBits = 0,
bool UseFillExpr = true) const;
/// GetTempSymbol - Return the MCSymbol corresponding to the assembler
/// temporary label with the specified stem and unique ID.
MCSymbol *GetTempSymbol(StringRef Name, unsigned ID) const;
/// GetTempSymbol - Return an assembler temporary label with the specified
/// stem.
MCSymbol *GetTempSymbol(StringRef Name) const;
/// GetSymbolWithGlobalValueBase - Return the MCSymbol for a symbol with
/// global value name as its base, with the specified suffix, and where the
/// symbol is forced to have private linkage if ForcePrivate is true.
@ -279,16 +298,7 @@ namespace llvm {
MCSymbol *GetBlockAddressSymbol(const BlockAddress *BA) const;
MCSymbol *GetBlockAddressSymbol(const BasicBlock *BB) const;
/// EmitBasicBlockStart - This method prints the label for the specified
/// MachineBasicBlock, an alignment (if present) and a comment describing
/// it if appropriate.
void EmitBasicBlockStart(const MachineBasicBlock *MBB) const;
/// EmitGlobalConstant - Print a general LLVM constant to the .s file.
void EmitGlobalConstant(const Constant *CV, unsigned AddrSpace = 0);
//===------------------------------------------------------------------===//
//===------------------------------------------------------------------===//
// Emission Helper Routines.
//===------------------------------------------------------------------===//
public:

View File

@ -962,9 +962,7 @@ 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++));
MCSymbol *SetLabel = GetTempSymbol("set", SetCounter++);
OutStreamer.EmitAssignment(SetLabel, Diff);
OutStreamer.EmitSymbolValue(SetLabel, Size, 0/*AddrSpace*/);
}
@ -1345,6 +1343,29 @@ void AsmPrinter::printOffset(int64_t Offset, raw_ostream &OS) const {
OS << Offset;
}
//===----------------------------------------------------------------------===//
// Symbol Lowering Routines.
//===----------------------------------------------------------------------===//
/// GetTempSymbol - Return the MCSymbol corresponding to the assembler
/// temporary label with the specified stem and unique ID.
MCSymbol *AsmPrinter::GetTempSymbol(StringRef Name, unsigned ID) const {
// FIXME: REMOVE this. However, there is stuff in EH that passes counters in
// here that can be zero.
//assert(ID && "Should use GetTempSymbol if no ID");
if (ID == 0) return GetTempSymbol(Name);
return OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix())+
Name + Twine(ID));
}
/// GetTempSymbol - Return an assembler temporary label with the specified
/// stem.
MCSymbol *AsmPrinter::GetTempSymbol(StringRef Name) const {
return OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix())+
Name);
}
MCSymbol *AsmPrinter::GetBlockAddressSymbol(const BlockAddress *BA) const {
return MMI->getAddrLabelSymbol(BA->getBasicBlock());

View File

@ -320,7 +320,7 @@ MCSymbol *DwarfDebug::getStringPoolEntry(StringRef Str) {
if (Entry.first) return Entry.first;
Entry.second = NextStringPoolNumber++;
return Entry.first = getDWLabel("string", Entry.second);
return Entry.first = Asm->GetTempSymbol("string", Entry.second);
}
@ -1351,9 +1351,9 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(MDNode *SPNode) {
}
addLabel(SPDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
getDWLabel("func_begin", SubprogramCount));
Asm->GetTempSymbol("func_begin", SubprogramCount));
addLabel(SPDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
getDWLabel("func_end", SubprogramCount));
Asm->GetTempSymbol("func_end", SubprogramCount));
MachineLocation Location(RI->getFrameRegister(*MF));
addAddress(SPDie, dwarf::DW_AT_frame_base, Location);
@ -1378,9 +1378,9 @@ DIE *DwarfDebug::constructLexicalScopeDIE(DbgScope *Scope) {
return ScopeDIE;
addLabel(ScopeDIE, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
Start ? Start : getDWLabel("func_begin", SubprogramCount));
Start ? Start : Asm->GetTempSymbol("func_begin", SubprogramCount));
addLabel(ScopeDIE, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
End ? End : getDWLabel("func_end", SubprogramCount));
End ? End : Asm->GetTempSymbol("func_end", SubprogramCount));
return ScopeDIE;
}
@ -1669,9 +1669,9 @@ void DwarfDebug::constructCompileUnit(MDNode *N) {
DIUnit.getLanguage());
addString(Die, dwarf::DW_AT_name, dwarf::DW_FORM_string, FN);
addLabel(Die, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
getTempLabel("text_begin"));
Asm->GetTempSymbol("text_begin"));
addLabel(Die, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
getTempLabel("text_end"));
Asm->GetTempSymbol("text_end"));
// DW_AT_stmt_list is a offset of line number information for this
// compile unit in debug_line section. It is always zero when only one
// compile unit is emitted in one object file.
@ -1872,14 +1872,14 @@ void DwarfDebug::endModule() {
// Standard sections final addresses.
Asm->OutStreamer.SwitchSection(Asm->getObjFileLowering().getTextSection());
Asm->OutStreamer.EmitLabel(getTempLabel("text_end"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("text_end"));
Asm->OutStreamer.SwitchSection(Asm->getObjFileLowering().getDataSection());
Asm->OutStreamer.EmitLabel(getTempLabel("data_end"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("data_end"));
// End text sections.
for (unsigned i = 1, N = SectionMap.size(); i <= N; ++i) {
Asm->OutStreamer.SwitchSection(SectionMap[i]);
Asm->OutStreamer.EmitLabel(getDWLabel("section_end", i));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_end", i));
}
// Emit common frame information.
@ -2255,7 +2255,8 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
collectVariableInfo();
// Assumes in correct section after the entry point.
Asm->OutStreamer.EmitLabel(getDWLabel("func_begin", ++SubprogramCount));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("func_begin",
++SubprogramCount));
// Emit label for the implicitly defined dbg.stoppoint at the start of the
// function.
@ -2287,7 +2288,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
if (CurrentFnDbgScope) {
// Define end label for subprogram.
Asm->OutStreamer.EmitLabel(getDWLabel("func_end", SubprogramCount));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("func_end", SubprogramCount));
// Get function line info.
if (!Lines.empty()) {
@ -2449,38 +2450,38 @@ void DwarfDebug::emitInitial() {
// Dwarf sections base addresses.
if (MAI->doesDwarfRequireFrameSection()) {
Asm->OutStreamer.SwitchSection(TLOF.getDwarfFrameSection());
Asm->OutStreamer.EmitLabel(getTempLabel("section_debug_frame"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_debug_frame"));
}
Asm->OutStreamer.SwitchSection(TLOF.getDwarfInfoSection());
Asm->OutStreamer.EmitLabel(getTempLabel("section_info"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_info"));
Asm->OutStreamer.SwitchSection(TLOF.getDwarfAbbrevSection());
Asm->OutStreamer.EmitLabel(getTempLabel("section_abbrev"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_abbrev"));
Asm->OutStreamer.SwitchSection(TLOF.getDwarfARangesSection());
Asm->OutStreamer.EmitLabel(getTempLabel("section_aranges"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_aranges"));
if (const MCSection *LineInfoDirective = TLOF.getDwarfMacroInfoSection()) {
Asm->OutStreamer.SwitchSection(LineInfoDirective);
Asm->OutStreamer.EmitLabel(getTempLabel("section_macinfo"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_macinfo"));
}
Asm->OutStreamer.SwitchSection(TLOF.getDwarfLineSection());
Asm->OutStreamer.EmitLabel(getTempLabel("section_line"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_line"));
Asm->OutStreamer.SwitchSection(TLOF.getDwarfLocSection());
Asm->OutStreamer.EmitLabel(getTempLabel("section_loc"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_loc"));
Asm->OutStreamer.SwitchSection(TLOF.getDwarfPubNamesSection());
Asm->OutStreamer.EmitLabel(getTempLabel("section_pubnames"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_pubnames"));
Asm->OutStreamer.SwitchSection(TLOF.getDwarfPubTypesSection());
Asm->OutStreamer.EmitLabel(getTempLabel("section_pubtypes"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_pubtypes"));
Asm->OutStreamer.SwitchSection(TLOF.getDwarfStrSection());
Asm->OutStreamer.EmitLabel(getTempLabel("section_str"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_str"));
Asm->OutStreamer.SwitchSection(TLOF.getDwarfRangesSection());
Asm->OutStreamer.EmitLabel(getTempLabel("section_ranges"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_ranges"));
Asm->OutStreamer.SwitchSection(TLOF.getTextSection());
Asm->OutStreamer.EmitLabel(getTempLabel("text_begin"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("text_begin"));
Asm->OutStreamer.SwitchSection(TLOF.getDataSection());
Asm->OutStreamer.EmitLabel(getTempLabel("data_begin"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("data_begin"));
}
/// emitDIE - Recusively Emits a debug information entry.
@ -2550,7 +2551,8 @@ void DwarfDebug::emitDebugInfo() {
DIE *Die = ModuleCU->getCUDie();
// Emit the compile units header.
Asm->OutStreamer.EmitLabel(getDWLabel("info_begin", ModuleCU->getID()));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("info_begin",
ModuleCU->getID()));
// Emit size of content not including length itself
unsigned ContentSize = Die->getSize() +
@ -2564,8 +2566,8 @@ void DwarfDebug::emitDebugInfo() {
Asm->OutStreamer.AddComment("DWARF version number");
Asm->EmitInt16(dwarf::DWARF_VERSION);
Asm->OutStreamer.AddComment("Offset Into Abbrev. Section");
EmitSectionOffset(getTempLabel("abbrev_begin"),getTempLabel("section_abbrev"),
true);
EmitSectionOffset(Asm->GetTempSymbol("abbrev_begin"),
Asm->GetTempSymbol("section_abbrev"), true);
Asm->OutStreamer.AddComment("Address Size (in bytes)");
Asm->EmitInt8(TD->getPointerSize());
@ -2576,7 +2578,7 @@ void DwarfDebug::emitDebugInfo() {
Asm->EmitInt8(0);
Asm->EmitInt8(0);
Asm->EmitInt8(0);
Asm->OutStreamer.EmitLabel(getDWLabel("info_end", ModuleCU->getID()));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("info_end", ModuleCU->getID()));
}
/// emitAbbreviations - Emit the abbreviation section.
@ -2588,7 +2590,7 @@ void DwarfDebug::emitAbbreviations() const {
Asm->OutStreamer.SwitchSection(
Asm->getObjFileLowering().getDwarfAbbrevSection());
Asm->OutStreamer.EmitLabel(getTempLabel("abbrev_begin"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("abbrev_begin"));
// For each abbrevation.
for (unsigned i = 0, N = Abbreviations.size(); i < N; ++i) {
@ -2605,7 +2607,7 @@ void DwarfDebug::emitAbbreviations() const {
// Mark end of abbreviations.
Asm->EmitULEB128(0, "EOM(3)");
Asm->OutStreamer.EmitLabel(getTempLabel("abbrev_end"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("abbrev_end"));
}
}
@ -2624,7 +2626,7 @@ void DwarfDebug::emitEndOfLineMatrix(unsigned SectionEnd) {
Asm->OutStreamer.AddComment("Section end label");
Asm->OutStreamer.EmitSymbolValue(getDWLabel("section_end", SectionEnd),
Asm->OutStreamer.EmitSymbolValue(Asm->GetTempSymbol("section_end",SectionEnd),
TD->getPointerSize(), 0/*AddrSpace*/);
// Mark end of matrix.
@ -2653,16 +2655,17 @@ void DwarfDebug::emitDebugLines() {
// Construct the section header.
Asm->OutStreamer.AddComment("Length of Source Line Info");
EmitDifference(getTempLabel("line_end"), getTempLabel("line_begin"), true);
Asm->OutStreamer.EmitLabel(getTempLabel("line_begin"));
EmitDifference(Asm->GetTempSymbol("line_end"),
Asm->GetTempSymbol("line_begin"), true);
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("line_begin"));
Asm->OutStreamer.AddComment("DWARF version number");
Asm->EmitInt16(dwarf::DWARF_VERSION);
Asm->OutStreamer.AddComment("Prolog Length");
EmitDifference(getTempLabel("line_prolog_end"),
getTempLabel("line_prolog_begin"), true);
Asm->OutStreamer.EmitLabel(getTempLabel("line_prolog_begin"));
EmitDifference(Asm->GetTempSymbol("line_prolog_end"),
Asm->GetTempSymbol("line_prolog_begin"), true);
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("line_prolog_begin"));
Asm->OutStreamer.AddComment("Minimum Instruction Length");
Asm->EmitInt8(1);
@ -2721,7 +2724,7 @@ void DwarfDebug::emitDebugLines() {
Asm->OutStreamer.AddComment("End of files");
Asm->EmitInt8(0);
Asm->OutStreamer.EmitLabel(getTempLabel("line_prolog_end"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("line_prolog_end"));
// A sequence for each text section.
unsigned SecSrcLinesSize = SectionSourceLines.size();
@ -2810,7 +2813,7 @@ void DwarfDebug::emitDebugLines() {
// put into it, emit an empty table.
emitEndOfLineMatrix(1);
Asm->OutStreamer.EmitLabel(getTempLabel("line_end"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("line_end"));
}
/// emitCommonDebugFrame - Emit common frame info into a debug frame section.
@ -2828,12 +2831,12 @@ void DwarfDebug::emitCommonDebugFrame() {
Asm->OutStreamer.SwitchSection(
Asm->getObjFileLowering().getDwarfFrameSection());
Asm->OutStreamer.EmitLabel(getTempLabel("debug_frame_common"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_frame_common"));
Asm->OutStreamer.AddComment("Length of Common Information Entry");
EmitDifference(getTempLabel("debug_frame_common_end"),
getTempLabel("debug_frame_common_begin"), true);
EmitDifference(Asm->GetTempSymbol("debug_frame_common_end"),
Asm->GetTempSymbol("debug_frame_common_begin"), true);
Asm->OutStreamer.EmitLabel(getTempLabel("debug_frame_common_begin"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_frame_common_begin"));
Asm->OutStreamer.AddComment("CIE Identifier Tag");
Asm->EmitInt32((int)dwarf::DW_CIE_ID);
Asm->OutStreamer.AddComment("CIE Version");
@ -2851,7 +2854,7 @@ void DwarfDebug::emitCommonDebugFrame() {
EmitFrameMoves(0, Moves, false);
Asm->EmitAlignment(2, 0, 0, false);
Asm->OutStreamer.EmitLabel(getTempLabel("debug_frame_common_end"));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_frame_common_end"));
}
/// emitFunctionDebugFrame - Emit per function frame info into a debug frame
@ -2867,25 +2870,27 @@ emitFunctionDebugFrame(const FunctionDebugFrameInfo &DebugFrameInfo) {
Asm->OutStreamer.AddComment("Length of Frame Information Entry");
MCSymbol *DebugFrameBegin =
getDWLabel("debug_frame_begin", DebugFrameInfo.Number);
Asm->GetTempSymbol("debug_frame_begin", DebugFrameInfo.Number);
MCSymbol *DebugFrameEnd =
getDWLabel("debug_frame_end", DebugFrameInfo.Number);
Asm->GetTempSymbol("debug_frame_end", DebugFrameInfo.Number);
EmitDifference(DebugFrameEnd, DebugFrameBegin, true);
Asm->OutStreamer.EmitLabel(DebugFrameBegin);
Asm->OutStreamer.AddComment("FDE CIE offset");
EmitSectionOffset(getTempLabel("debug_frame_common"),
getTempLabel("section_debug_frame"), true);
EmitSectionOffset(Asm->GetTempSymbol("debug_frame_common"),
Asm->GetTempSymbol("section_debug_frame"), true);
Asm->OutStreamer.AddComment("FDE initial location");
MCSymbol *FuncBeginSym = getDWLabel("func_begin", DebugFrameInfo.Number);
MCSymbol *FuncBeginSym =
Asm->GetTempSymbol("func_begin", DebugFrameInfo.Number);
Asm->OutStreamer.EmitSymbolValue(FuncBeginSym,
TD->getPointerSize(), 0/*AddrSpace*/);
Asm->OutStreamer.AddComment("FDE address range");
EmitDifference(getDWLabel("func_end", DebugFrameInfo.Number), FuncBeginSym);
EmitDifference(Asm->GetTempSymbol("func_end", DebugFrameInfo.Number),
FuncBeginSym);
EmitFrameMoves(FuncBeginSym, DebugFrameInfo.Moves, false);
@ -2901,21 +2906,22 @@ void DwarfDebug::emitDebugPubNames() {
Asm->getObjFileLowering().getDwarfPubNamesSection());
Asm->OutStreamer.AddComment("Length of Public Names Info");
EmitDifference(getDWLabel("pubnames_end", ModuleCU->getID()),
getDWLabel("pubnames_begin", ModuleCU->getID()), true);
EmitDifference(Asm->GetTempSymbol("pubnames_end", ModuleCU->getID()),
Asm->GetTempSymbol("pubnames_begin", ModuleCU->getID()), true);
Asm->OutStreamer.EmitLabel(getDWLabel("pubnames_begin", ModuleCU->getID()));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("pubnames_begin",
ModuleCU->getID()));
Asm->OutStreamer.AddComment("DWARF Version");
Asm->EmitInt16(dwarf::DWARF_VERSION);
Asm->OutStreamer.AddComment("Offset of Compilation Unit Info");
EmitSectionOffset(getDWLabel("info_begin", ModuleCU->getID()),
getTempLabel("section_info"), true);
EmitSectionOffset(Asm->GetTempSymbol("info_begin", ModuleCU->getID()),
Asm->GetTempSymbol("section_info"), true);
Asm->OutStreamer.AddComment("Compilation Unit Length");
EmitDifference(getDWLabel("info_end", ModuleCU->getID()),
getDWLabel("info_begin", ModuleCU->getID()),
EmitDifference(Asm->GetTempSymbol("info_end", ModuleCU->getID()),
Asm->GetTempSymbol("info_begin", ModuleCU->getID()),
true);
const StringMap<DIE*> &Globals = ModuleCU->getGlobals();
@ -2934,7 +2940,8 @@ void DwarfDebug::emitDebugPubNames() {
Asm->OutStreamer.AddComment("End Mark");
Asm->EmitInt32(0);
Asm->OutStreamer.EmitLabel(getDWLabel("pubnames_end", ModuleCU->getID()));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("pubnames_end",
ModuleCU->getID()));
}
void DwarfDebug::emitDebugPubTypes() {
@ -2942,21 +2949,22 @@ void DwarfDebug::emitDebugPubTypes() {
Asm->OutStreamer.SwitchSection(
Asm->getObjFileLowering().getDwarfPubTypesSection());
Asm->OutStreamer.AddComment("Length of Public Types Info");
EmitDifference(getDWLabel("pubtypes_end", ModuleCU->getID()),
getDWLabel("pubtypes_begin", ModuleCU->getID()), true);
EmitDifference(Asm->GetTempSymbol("pubtypes_end", ModuleCU->getID()),
Asm->GetTempSymbol("pubtypes_begin", ModuleCU->getID()), true);
Asm->OutStreamer.EmitLabel(getDWLabel("pubtypes_begin", ModuleCU->getID()));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("pubtypes_begin",
ModuleCU->getID()));
if (Asm->isVerbose()) Asm->OutStreamer.AddComment("DWARF Version");
Asm->EmitInt16(dwarf::DWARF_VERSION);
Asm->OutStreamer.AddComment("Offset of Compilation ModuleCU Info");
EmitSectionOffset(getDWLabel("info_begin", ModuleCU->getID()),
getTempLabel("section_info"), true);
EmitSectionOffset(Asm->GetTempSymbol("info_begin", ModuleCU->getID()),
Asm->GetTempSymbol("section_info"), true);
Asm->OutStreamer.AddComment("Compilation ModuleCU Length");
EmitDifference(getDWLabel("info_end", ModuleCU->getID()),
getDWLabel("info_begin", ModuleCU->getID()),
EmitDifference(Asm->GetTempSymbol("info_end", ModuleCU->getID()),
Asm->GetTempSymbol("info_begin", ModuleCU->getID()),
true);
const StringMap<DIE*> &Globals = ModuleCU->getGlobalTypes();
@ -2974,7 +2982,8 @@ void DwarfDebug::emitDebugPubTypes() {
Asm->OutStreamer.AddComment("End Mark");
Asm->EmitInt32(0);
Asm->OutStreamer.EmitLabel(getDWLabel("pubtypes_end", ModuleCU->getID()));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("pubtypes_end",
ModuleCU->getID()));
}
/// emitDebugStr - Emit visible names into a debug str section.
@ -3070,10 +3079,10 @@ void DwarfDebug::emitDebugInlineInfo() {
Asm->getObjFileLowering().getDwarfDebugInlineSection());
Asm->OutStreamer.AddComment("Length of Debug Inlined Information Entry");
EmitDifference(getDWLabel("debug_inlined_end", 1),
getDWLabel("debug_inlined_begin", 1), true);
EmitDifference(Asm->GetTempSymbol("debug_inlined_end", 1),
Asm->GetTempSymbol("debug_inlined_begin", 1), true);
Asm->OutStreamer.EmitLabel(getDWLabel("debug_inlined_begin", 1));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_inlined_begin", 1));
Asm->OutStreamer.AddComment("Dwarf Version");
Asm->EmitInt16(dwarf::DWARF_VERSION);
@ -3097,11 +3106,11 @@ void DwarfDebug::emitDebugInlineInfo() {
Asm->OutStreamer.EmitIntValue(0, 1, 0); // nul terminator.
} else
EmitSectionOffset(getStringPoolEntry(getRealLinkageName(LName)),
getTempLabel("section_str"), true);
Asm->GetTempSymbol("section_str"), true);
Asm->OutStreamer.AddComment("Function name");
EmitSectionOffset(getStringPoolEntry(Name), getTempLabel("section_str"),
true);
EmitSectionOffset(getStringPoolEntry(Name),
Asm->GetTempSymbol("section_str"), true);
Asm->EmitULEB128(Labels.size(), "Inline count");
for (SmallVector<InlineInfoLabels, 4>::iterator LI = Labels.begin(),
@ -3114,5 +3123,5 @@ void DwarfDebug::emitDebugInlineInfo() {
}
}
Asm->OutStreamer.EmitLabel(getDWLabel("debug_inlined_end", 1));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_inlined_end", 1));
}

View File

@ -67,24 +67,24 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
MCSymbol *EHFrameSym;
if (TLOF.isFunctionEHFrameSymbolPrivate())
EHFrameSym = getDWLabel("EH_frame", Index);
EHFrameSym = Asm->GetTempSymbol("EH_frame", Index);
else
EHFrameSym = Asm->OutContext.GetOrCreateSymbol(Twine("EH_frame") +
Twine(Index));
Asm->OutStreamer.EmitLabel(EHFrameSym);
Asm->OutStreamer.EmitLabel(getDWLabel("section_eh_frame", Index));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_eh_frame", Index));
// Define base labels.
Asm->OutStreamer.EmitLabel(getDWLabel("eh_frame_common", Index));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_common", Index));
// Define the eh frame length.
Asm->OutStreamer.AddComment("Length of Common Information Entry");
EmitDifference(getDWLabel("eh_frame_common_end", Index),
getDWLabel("eh_frame_common_begin", Index), true);
EmitDifference(Asm->GetTempSymbol("eh_frame_common_end", Index),
Asm->GetTempSymbol("eh_frame_common_begin", Index), true);
// EH frame header.
Asm->OutStreamer.EmitLabel(getDWLabel("eh_frame_common_begin", Index));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_common_begin",Index));
Asm->OutStreamer.AddComment("CIE Identifier Tag");
Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
Asm->OutStreamer.AddComment("DW_CIE_VERSION");
@ -156,7 +156,7 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
// be 8-byte on 64-bit targets to match what gcc does. Otherwise you get
// holes which confuse readers of eh_frame.
Asm->EmitAlignment(TD->getPointerSize() == 4 ? 2 : 3, 0, 0, false);
Asm->OutStreamer.EmitLabel(getDWLabel("eh_frame_common_end", Index));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_common_end", Index));
}
/// EmitFDE - Emit the Frame Description Entry (FDE) for the function.
@ -209,26 +209,28 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
// EH frame header.
Asm->OutStreamer.AddComment("Length of Frame Information Entry");
EmitDifference(getDWLabel("eh_frame_end", EHFrameInfo.Number),
getDWLabel("eh_frame_begin", EHFrameInfo.Number),
EmitDifference(Asm->GetTempSymbol("eh_frame_end", EHFrameInfo.Number),
Asm->GetTempSymbol("eh_frame_begin", EHFrameInfo.Number),
true);
Asm->OutStreamer.EmitLabel(getDWLabel("eh_frame_begin",EHFrameInfo.Number));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_begin",
EHFrameInfo.Number));
Asm->OutStreamer.AddComment("FDE CIE offset");
EmitSectionOffset(getDWLabel("eh_frame_begin", EHFrameInfo.Number),
getDWLabel("eh_frame_common",
EHFrameInfo.PersonalityIndex),
EmitSectionOffset(Asm->GetTempSymbol("eh_frame_begin", EHFrameInfo.Number),
Asm->GetTempSymbol("eh_frame_common",
EHFrameInfo.PersonalityIndex),
true, true);
MCSymbol *EHFuncBeginSym = getDWLabel("eh_func_begin", EHFrameInfo.Number);
MCSymbol *EHFuncBeginSym =
Asm->GetTempSymbol("eh_func_begin", EHFrameInfo.Number);
Asm->OutStreamer.AddComment("FDE initial location");
EmitReference(EHFuncBeginSym, FDEEncoding);
Asm->OutStreamer.AddComment("FDE address range");
EmitDifference(getDWLabel("eh_func_end", EHFrameInfo.Number),EHFuncBeginSym,
SizeOfEncodedValue(FDEEncoding) == 4);
EmitDifference(Asm->GetTempSymbol("eh_func_end", EHFrameInfo.Number),
EHFuncBeginSym, SizeOfEncodedValue(FDEEncoding) == 4);
// If there is a personality and landing pads then point to the language
// specific data area in the exception table.
@ -238,7 +240,8 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
Asm->EmitULEB128(Size, "Augmentation size");
Asm->OutStreamer.AddComment("Language Specific Data Area");
if (EHFrameInfo.hasLandingPads)
EmitReference(getDWLabel("exception", EHFrameInfo.Number),LSDAEncoding);
EmitReference(Asm->GetTempSymbol("exception", EHFrameInfo.Number),
LSDAEncoding);
else
Asm->OutStreamer.EmitIntValue(0, Size/*size*/, 0/*addrspace*/);
@ -254,7 +257,8 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
// get holes which confuse readers of eh_frame.
Asm->EmitAlignment(TD->getPointerSize() == sizeof(int32_t) ? 2 : 3,
0, 0, false);
Asm->OutStreamer.EmitLabel(getDWLabel("eh_frame_end", EHFrameInfo.Number));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_end",
EHFrameInfo.Number));
// If the function is marked used, this table should be also. We cannot
// make the mark unconditional in this case, since retaining the table also
@ -686,10 +690,11 @@ void DwarfException::EmitExceptionTable() {
Asm->OutContext.GetOrCreateSymbol(Twine("GCC_except_table")+
Twine(SubprogramCount));
Asm->OutStreamer.EmitLabel(GCCETSym);
Asm->OutStreamer.EmitLabel(getDWLabel("exception", SubprogramCount));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("exception", SubprogramCount));
if (IsSJLJ)
Asm->OutStreamer.EmitLabel(getDWLabel("_LSDA_", Asm->getFunctionNumber()));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("_LSDA_",
Asm->getFunctionNumber()));
// Emit the LSDA header.
EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart");
@ -788,14 +793,15 @@ void DwarfException::EmitExceptionTable() {
I = CallSites.begin(), E = CallSites.end(); I != E; ++I) {
const CallSiteEntry &S = *I;
MCSymbol *EHFuncBeginSym = getDWLabel("eh_func_begin", SubprogramCount);
MCSymbol *EHFuncBeginSym =
Asm->GetTempSymbol("eh_func_begin", SubprogramCount);
MCSymbol *BeginLabel = S.BeginLabel;
if (BeginLabel == 0)
BeginLabel = EHFuncBeginSym;
MCSymbol *EndLabel = S.EndLabel;
if (EndLabel == 0)
EndLabel = getDWLabel("eh_func_end", SubprogramCount);
EndLabel = Asm->GetTempSymbol("eh_func_end", SubprogramCount);
// Offset of the call site relative to the previous call site, counted in
// number of 16-byte bundles. The first call site is counted relative to
@ -915,7 +921,8 @@ void DwarfException::BeginFunction(const MachineFunction *MF) {
if (shouldEmitMoves || shouldEmitTable)
// Assumes in correct section after the entry point.
Asm->OutStreamer.EmitLabel(getDWLabel("eh_func_begin", ++SubprogramCount));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin",
++SubprogramCount));
shouldEmitTableModule |= shouldEmitTable;
shouldEmitMovesModule |= shouldEmitMoves;
@ -927,7 +934,7 @@ void DwarfException::EndFunction() {
if (!shouldEmitMoves && !shouldEmitTable) return;
TimeRegion Timer(ExceptionTimer);
Asm->OutStreamer.EmitLabel(getDWLabel("eh_func_end", SubprogramCount));
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end",SubprogramCount));
// Record if this personality index uses a landing pad.
bool HasLandingPad = !MMI->getLandingPads().empty();

View File

@ -37,27 +37,6 @@ DwarfPrinter::DwarfPrinter(AsmPrinter *A)
RI(Asm->TM.getRegisterInfo()), M(NULL), MF(NULL), MMI(NULL),
SubprogramCount(0) {}
/// getDWLabel - Return the MCSymbol corresponding to the assembler temporary
/// label with the specified stem and unique ID.
MCSymbol *DwarfPrinter::getDWLabel(const char *Name, unsigned ID) const {
// FIXME: REMOVE this. However, there is stuff in EH that passes counters in
// here that can be zero.
//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));
}
/// 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);
}
/// SizeOfEncodedValue - Return the size of the encoding in bytes.
unsigned DwarfPrinter::SizeOfEncodedValue(unsigned Encoding) const {
if (Encoding == dwarf::DW_EH_PE_omit)

View File

@ -74,14 +74,6 @@ public:
const MCAsmInfo *getMCAsmInfo() const { return MAI; }
const TargetData *getTargetData() const { return TD; }
/// getDWLabel - Return the MCSymbol corresponding to the assembler temporary
/// label with the specified stem and unique ID.
MCSymbol *getDWLabel(const char *Name, unsigned ID) const;
/// getTempLabel - Return an assembler temporary label with the specified
/// name.
MCSymbol *getTempLabel(const char *Name) const;
/// SizeOfEncodedValue - Return the size of the encoding in bytes.
unsigned SizeOfEncodedValue(unsigned Encoding) const;