1 //===-- llvm/CodeGen/DwarfDebug.cpp - Dwarf Debug Framework ---------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains support for writing dwarf debug info into asm files.
12 //===----------------------------------------------------------------------===//
14 #include "DwarfDebug.h"
15 #include "llvm/Module.h"
16 #include "llvm/CodeGen/MachineModuleInfo.h"
17 #include "llvm/Support/Timer.h"
18 #include "llvm/System/Path.h"
19 #include "llvm/Target/TargetAsmInfo.h"
20 #include "llvm/Target/TargetRegisterInfo.h"
21 #include "llvm/Target/TargetData.h"
22 #include "llvm/Target/TargetFrameInfo.h"
26 static TimerGroup &getDwarfTimerGroup() {
27 static TimerGroup DwarfTimerGroup("Dwarf Debugging");
28 return DwarfTimerGroup;
31 //===----------------------------------------------------------------------===//
33 /// Configuration values for initial hash set sizes (log2).
35 static const unsigned InitDiesSetSize = 9; // log2(512)
36 static const unsigned InitAbbreviationsSetSize = 9; // log2(512)
37 static const unsigned InitValuesSetSize = 9; // log2(512)
41 //===----------------------------------------------------------------------===//
42 /// CompileUnit - This dwarf writer support class manages information associate
43 /// with a source file.
44 class VISIBILITY_HIDDEN CompileUnit {
45 /// ID - File identifier for source.
49 /// Die - Compile unit debug information entry.
53 /// GVToDieMap - Tracks the mapping of unit level debug informaton
54 /// variables to debug information entries.
55 std::map<GlobalVariable *, DIE *> GVToDieMap;
57 /// GVToDIEEntryMap - Tracks the mapping of unit level debug informaton
58 /// descriptors to debug information entries using a DIEEntry proxy.
59 std::map<GlobalVariable *, DIEEntry *> GVToDIEEntryMap;
61 /// Globals - A map of globally visible named entities for this unit.
63 StringMap<DIE*> Globals;
65 /// DiesSet - Used to uniquely define dies within the compile unit.
67 FoldingSet<DIE> DiesSet;
69 CompileUnit(unsigned I, DIE *D)
70 : ID(I), Die(D), GVToDieMap(),
71 GVToDIEEntryMap(), Globals(), DiesSet(InitDiesSetSize)
79 unsigned getID() const { return ID; }
80 DIE* getDie() const { return Die; }
81 StringMap<DIE*> &getGlobals() { return Globals; }
83 /// hasContent - Return true if this compile unit has something to write out.
85 bool hasContent() const {
86 return !Die->getChildren().empty();
89 /// AddGlobal - Add a new global entity to the compile unit.
91 void AddGlobal(const std::string &Name, DIE *Die) {
95 /// getDieMapSlotFor - Returns the debug information entry map slot for the
96 /// specified debug variable.
97 DIE *&getDieMapSlotFor(GlobalVariable *GV) {
98 return GVToDieMap[GV];
101 /// getDIEEntrySlotFor - Returns the debug information entry proxy slot for the
102 /// specified debug variable.
103 DIEEntry *&getDIEEntrySlotFor(GlobalVariable *GV) {
104 return GVToDIEEntryMap[GV];
107 /// AddDie - Adds or interns the DIE to the compile unit.
109 DIE *AddDie(DIE &Buffer) {
113 DIE *Die = DiesSet.FindNodeOrInsertPos(ID, Where);
116 Die = new DIE(Buffer);
117 DiesSet.InsertNode(Die, Where);
118 this->Die->AddChild(Die);
126 //===----------------------------------------------------------------------===//
127 /// DbgVariable - This class is used to track local variable information.
129 class VISIBILITY_HIDDEN DbgVariable {
130 DIVariable Var; // Variable Descriptor.
131 unsigned FrameIndex; // Variable frame index.
132 bool InlinedFnVar; // Variable for an inlined function.
134 DbgVariable(DIVariable V, unsigned I, bool IFV)
135 : Var(V), FrameIndex(I), InlinedFnVar(IFV) {}
138 DIVariable getVariable() const { return Var; }
139 unsigned getFrameIndex() const { return FrameIndex; }
140 bool isInlinedFnVar() const { return InlinedFnVar; }
143 //===----------------------------------------------------------------------===//
144 /// DbgScope - This class is used to track scope information.
146 class DbgConcreteScope;
147 class VISIBILITY_HIDDEN DbgScope {
148 DbgScope *Parent; // Parent to this scope.
149 DIDescriptor Desc; // Debug info descriptor for scope.
150 // Either subprogram or block.
151 unsigned StartLabelID; // Label ID of the beginning of scope.
152 unsigned EndLabelID; // Label ID of the end of scope.
153 SmallVector<DbgScope *, 4> Scopes; // Scopes defined in scope.
154 SmallVector<DbgVariable *, 8> Variables;// Variables declared in scope.
155 SmallVector<DbgConcreteScope *, 8> ConcreteInsts;// Concrete insts of funcs.
157 DbgScope(DbgScope *P, DIDescriptor D)
158 : Parent(P), Desc(D), StartLabelID(0), EndLabelID(0) {}
162 DbgScope *getParent() const { return Parent; }
163 DIDescriptor getDesc() const { return Desc; }
164 unsigned getStartLabelID() const { return StartLabelID; }
165 unsigned getEndLabelID() const { return EndLabelID; }
166 SmallVector<DbgScope *, 4> &getScopes() { return Scopes; }
167 SmallVector<DbgVariable *, 8> &getVariables() { return Variables; }
168 SmallVector<DbgConcreteScope*,8> &getConcreteInsts() { return ConcreteInsts; }
169 void setStartLabelID(unsigned S) { StartLabelID = S; }
170 void setEndLabelID(unsigned E) { EndLabelID = E; }
172 /// AddScope - Add a scope to the scope.
174 void AddScope(DbgScope *S) { Scopes.push_back(S); }
176 /// AddVariable - Add a variable to the scope.
178 void AddVariable(DbgVariable *V) { Variables.push_back(V); }
180 /// AddConcreteInst - Add a concrete instance to the scope.
182 void AddConcreteInst(DbgConcreteScope *C) { ConcreteInsts.push_back(C); }
190 void DbgScope::dump() const {
191 static unsigned IndentLevel = 0;
192 std::string Indent(IndentLevel, ' ');
194 cerr << Indent; Desc.dump();
195 cerr << " [" << StartLabelID << ", " << EndLabelID << "]\n";
199 for (unsigned i = 0, e = Scopes.size(); i != e; ++i)
200 if (Scopes[i] != this)
207 //===----------------------------------------------------------------------===//
208 /// DbgConcreteScope - This class is used to track a scope that holds concrete
209 /// instance information.
211 class VISIBILITY_HIDDEN DbgConcreteScope : public DbgScope {
213 DIE *Die; // Debug info for this concrete scope.
215 DbgConcreteScope(DIDescriptor D) : DbgScope(NULL, D) {}
218 DIE *getDie() const { return Die; }
219 void setDie(DIE *D) { Die = D; }
222 DbgScope::~DbgScope() {
223 for (unsigned i = 0, N = Scopes.size(); i < N; ++i)
225 for (unsigned j = 0, M = Variables.size(); j < M; ++j)
227 for (unsigned k = 0, O = ConcreteInsts.size(); k < O; ++k)
228 delete ConcreteInsts[k];
231 } // end llvm namespace
233 DwarfDebug::DwarfDebug(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
234 : Dwarf(OS, A, T, "dbg"), MainCU(0),
235 AbbreviationsSet(InitAbbreviationsSetSize), Abbreviations(),
236 ValuesSet(InitValuesSetSize), Values(), StringPool(), SectionMap(),
237 SectionSourceLines(), didInitial(false), shouldEmit(false),
238 FunctionDbgScope(0), DebugTimer(0) {
239 if (TimePassesIsEnabled)
240 DebugTimer = new Timer("Dwarf Debug Writer",
241 getDwarfTimerGroup());
243 DwarfDebug::~DwarfDebug() {
244 for (unsigned j = 0, M = Values.size(); j < M; ++j)
247 for (DenseMap<const GlobalVariable *, DbgScope *>::iterator
248 I = AbstractInstanceRootMap.begin(),
249 E = AbstractInstanceRootMap.end(); I != E;++I)
255 /// AssignAbbrevNumber - Define a unique number for the abbreviation.
257 void DwarfDebug::AssignAbbrevNumber(DIEAbbrev &Abbrev) {
258 // Profile the node so that we can make it unique.
262 // Check the set for priors.
263 DIEAbbrev *InSet = AbbreviationsSet.GetOrInsertNode(&Abbrev);
265 // If it's newly added.
266 if (InSet == &Abbrev) {
267 // Add to abbreviation list.
268 Abbreviations.push_back(&Abbrev);
270 // Assign the vector position + 1 as its number.
271 Abbrev.setNumber(Abbreviations.size());
273 // Assign existing abbreviation number.
274 Abbrev.setNumber(InSet->getNumber());
278 /// NewDIEEntry - Creates a new DIEEntry to be a proxy for a debug information
280 DIEEntry *DwarfDebug::NewDIEEntry(DIE *Entry) {
285 DIEEntry::Profile(ID, Entry);
287 Value = static_cast<DIEEntry *>(ValuesSet.FindNodeOrInsertPos(ID, Where));
289 if (Value) return Value;
291 Value = new DIEEntry(Entry);
292 ValuesSet.InsertNode(Value, Where);
294 Value = new DIEEntry(Entry);
297 Values.push_back(Value);
301 /// SetDIEEntry - Set a DIEEntry once the debug information entry is defined.
303 void DwarfDebug::SetDIEEntry(DIEEntry *Value, DIE *Entry) {
304 Value->setEntry(Entry);
306 // Add to values set if not already there. If it is, we merely have a
307 // duplicate in the values list (no harm.)
308 ValuesSet.GetOrInsertNode(Value);
311 /// AddUInt - Add an unsigned integer attribute data and value.
313 void DwarfDebug::AddUInt(DIE *Die, unsigned Attribute,
314 unsigned Form, uint64_t Integer) {
315 if (!Form) Form = DIEInteger::BestForm(false, Integer);
318 DIEInteger::Profile(ID, Integer);
320 DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
323 Value = new DIEInteger(Integer);
324 ValuesSet.InsertNode(Value, Where);
325 Values.push_back(Value);
328 Die->AddValue(Attribute, Form, Value);
331 /// AddSInt - Add an signed integer attribute data and value.
333 void DwarfDebug::AddSInt(DIE *Die, unsigned Attribute,
334 unsigned Form, int64_t Integer) {
335 if (!Form) Form = DIEInteger::BestForm(true, Integer);
338 DIEInteger::Profile(ID, (uint64_t)Integer);
340 DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
343 Value = new DIEInteger(Integer);
344 ValuesSet.InsertNode(Value, Where);
345 Values.push_back(Value);
348 Die->AddValue(Attribute, Form, Value);
351 /// AddString - Add a string attribute data and value.
353 void DwarfDebug::AddString(DIE *Die, unsigned Attribute, unsigned Form,
354 const std::string &String) {
356 DIEString::Profile(ID, String);
358 DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
361 Value = new DIEString(String);
362 ValuesSet.InsertNode(Value, Where);
363 Values.push_back(Value);
366 Die->AddValue(Attribute, Form, Value);
369 /// AddLabel - Add a Dwarf label attribute data and value.
371 void DwarfDebug::AddLabel(DIE *Die, unsigned Attribute, unsigned Form,
372 const DWLabel &Label) {
374 DIEDwarfLabel::Profile(ID, Label);
376 DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
379 Value = new DIEDwarfLabel(Label);
380 ValuesSet.InsertNode(Value, Where);
381 Values.push_back(Value);
384 Die->AddValue(Attribute, Form, Value);
387 /// AddObjectLabel - Add an non-Dwarf label attribute data and value.
389 void DwarfDebug::AddObjectLabel(DIE *Die, unsigned Attribute, unsigned Form,
390 const std::string &Label) {
392 DIEObjectLabel::Profile(ID, Label);
394 DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
397 Value = new DIEObjectLabel(Label);
398 ValuesSet.InsertNode(Value, Where);
399 Values.push_back(Value);
402 Die->AddValue(Attribute, Form, Value);
405 /// AddSectionOffset - Add a section offset label attribute data and value.
407 void DwarfDebug::AddSectionOffset(DIE *Die, unsigned Attribute, unsigned Form,
408 const DWLabel &Label, const DWLabel &Section,
409 bool isEH, bool useSet) {
411 DIESectionOffset::Profile(ID, Label, Section);
413 DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
416 Value = new DIESectionOffset(Label, Section, isEH, useSet);
417 ValuesSet.InsertNode(Value, Where);
418 Values.push_back(Value);
421 Die->AddValue(Attribute, Form, Value);
424 /// AddDelta - Add a label delta attribute data and value.
426 void DwarfDebug::AddDelta(DIE *Die, unsigned Attribute, unsigned Form,
427 const DWLabel &Hi, const DWLabel &Lo) {
429 DIEDelta::Profile(ID, Hi, Lo);
431 DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
434 Value = new DIEDelta(Hi, Lo);
435 ValuesSet.InsertNode(Value, Where);
436 Values.push_back(Value);
439 Die->AddValue(Attribute, Form, Value);
442 /// AddBlock - Add block data.
444 void DwarfDebug::AddBlock(DIE *Die, unsigned Attribute, unsigned Form,
446 Block->ComputeSize(TD);
450 DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
454 ValuesSet.InsertNode(Value, Where);
455 Values.push_back(Value);
457 // Already exists, reuse the previous one.
459 Block = cast<DIEBlock>(Value);
462 Die->AddValue(Attribute, Block->BestForm(), Value);
465 /// AddSourceLine - Add location information to specified debug information
467 void DwarfDebug::AddSourceLine(DIE *Die, const DIVariable *V) {
468 // If there is no compile unit specified, don't add a line #.
469 if (V->getCompileUnit().isNull())
472 unsigned Line = V->getLineNumber();
473 unsigned FileID = FindCompileUnit(V->getCompileUnit()).getID();
474 assert(FileID && "Invalid file id");
475 AddUInt(Die, dwarf::DW_AT_decl_file, 0, FileID);
476 AddUInt(Die, dwarf::DW_AT_decl_line, 0, Line);
479 /// AddSourceLine - Add location information to specified debug information
481 void DwarfDebug::AddSourceLine(DIE *Die, const DIGlobal *G) {
482 // If there is no compile unit specified, don't add a line #.
483 if (G->getCompileUnit().isNull())
486 unsigned Line = G->getLineNumber();
487 unsigned FileID = FindCompileUnit(G->getCompileUnit()).getID();
488 assert(FileID && "Invalid file id");
489 AddUInt(Die, dwarf::DW_AT_decl_file, 0, FileID);
490 AddUInt(Die, dwarf::DW_AT_decl_line, 0, Line);
492 void DwarfDebug::AddSourceLine(DIE *Die, const DIType *Ty) {
493 // If there is no compile unit specified, don't add a line #.
494 DICompileUnit CU = Ty->getCompileUnit();
498 unsigned Line = Ty->getLineNumber();
499 unsigned FileID = FindCompileUnit(CU).getID();
500 assert(FileID && "Invalid file id");
501 AddUInt(Die, dwarf::DW_AT_decl_file, 0, FileID);
502 AddUInt(Die, dwarf::DW_AT_decl_line, 0, Line);
505 /// AddAddress - Add an address attribute to a die based on the location
507 void DwarfDebug::AddAddress(DIE *Die, unsigned Attribute,
508 const MachineLocation &Location) {
509 unsigned Reg = RI->getDwarfRegNum(Location.getReg(), false);
510 DIEBlock *Block = new DIEBlock();
512 if (Location.isReg()) {
514 AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_reg0 + Reg);
516 AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_regx);
517 AddUInt(Block, 0, dwarf::DW_FORM_udata, Reg);
521 AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_breg0 + Reg);
523 AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_bregx);
524 AddUInt(Block, 0, dwarf::DW_FORM_udata, Reg);
527 AddUInt(Block, 0, dwarf::DW_FORM_sdata, Location.getOffset());
530 AddBlock(Die, Attribute, 0, Block);
533 /// AddType - Add a new type attribute to the specified entity.
534 void DwarfDebug::AddType(CompileUnit *DW_Unit, DIE *Entity, DIType Ty) {
538 // Check for pre-existence.
539 DIEEntry *&Slot = DW_Unit->getDIEEntrySlotFor(Ty.getGV());
541 // If it exists then use the existing value.
543 Entity->AddValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, Slot);
548 Slot = NewDIEEntry();
551 DIE Buffer(dwarf::DW_TAG_base_type);
552 if (Ty.isBasicType(Ty.getTag()))
553 ConstructTypeDIE(DW_Unit, Buffer, DIBasicType(Ty.getGV()));
554 else if (Ty.isDerivedType(Ty.getTag()))
555 ConstructTypeDIE(DW_Unit, Buffer, DIDerivedType(Ty.getGV()));
557 assert(Ty.isCompositeType(Ty.getTag()) && "Unknown kind of DIType");
558 ConstructTypeDIE(DW_Unit, Buffer, DICompositeType(Ty.getGV()));
561 // Add debug information entry to entity and appropriate context.
563 DIDescriptor Context = Ty.getContext();
564 if (!Context.isNull())
565 Die = DW_Unit->getDieMapSlotFor(Context.getGV());
568 DIE *Child = new DIE(Buffer);
569 Die->AddChild(Child);
571 SetDIEEntry(Slot, Child);
573 Die = DW_Unit->AddDie(Buffer);
574 SetDIEEntry(Slot, Die);
577 Entity->AddValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, Slot);
580 /// ConstructTypeDIE - Construct basic type die from DIBasicType.
581 void DwarfDebug::ConstructTypeDIE(CompileUnit *DW_Unit, DIE &Buffer,
583 // Get core information.
586 Buffer.setTag(dwarf::DW_TAG_base_type);
587 AddUInt(&Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
590 // Add name if not anonymous or intermediate type.
592 AddString(&Buffer, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
593 uint64_t Size = BTy.getSizeInBits() >> 3;
594 AddUInt(&Buffer, dwarf::DW_AT_byte_size, 0, Size);
597 /// ConstructTypeDIE - Construct derived type die from DIDerivedType.
598 void DwarfDebug::ConstructTypeDIE(CompileUnit *DW_Unit, DIE &Buffer,
600 // Get core information.
603 uint64_t Size = DTy.getSizeInBits() >> 3;
604 unsigned Tag = DTy.getTag();
606 // FIXME - Workaround for templates.
607 if (Tag == dwarf::DW_TAG_inheritance) Tag = dwarf::DW_TAG_reference_type;
611 // Map to main type, void will not have a type.
612 DIType FromTy = DTy.getTypeDerivedFrom();
613 AddType(DW_Unit, &Buffer, FromTy);
615 // Add name if not anonymous or intermediate type.
617 AddString(&Buffer, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
619 // Add size if non-zero (derived types might be zero-sized.)
621 AddUInt(&Buffer, dwarf::DW_AT_byte_size, 0, Size);
623 // Add source line info if available and TyDesc is not a forward declaration.
624 if (!DTy.isForwardDecl())
625 AddSourceLine(&Buffer, &DTy);
628 /// ConstructTypeDIE - Construct type DIE from DICompositeType.
629 void DwarfDebug::ConstructTypeDIE(CompileUnit *DW_Unit, DIE &Buffer,
630 DICompositeType CTy) {
631 // Get core information.
635 uint64_t Size = CTy.getSizeInBits() >> 3;
636 unsigned Tag = CTy.getTag();
640 case dwarf::DW_TAG_vector_type:
641 case dwarf::DW_TAG_array_type:
642 ConstructArrayTypeDIE(DW_Unit, Buffer, &CTy);
644 case dwarf::DW_TAG_enumeration_type: {
645 DIArray Elements = CTy.getTypeArray();
647 // Add enumerators to enumeration type.
648 for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
650 DIEnumerator Enum(Elements.getElement(i).getGV());
651 ElemDie = ConstructEnumTypeDIE(DW_Unit, &Enum);
652 Buffer.AddChild(ElemDie);
656 case dwarf::DW_TAG_subroutine_type: {
658 DIArray Elements = CTy.getTypeArray();
659 DIDescriptor RTy = Elements.getElement(0);
660 AddType(DW_Unit, &Buffer, DIType(RTy.getGV()));
662 // Add prototype flag.
663 AddUInt(&Buffer, dwarf::DW_AT_prototyped, dwarf::DW_FORM_flag, 1);
666 for (unsigned i = 1, N = Elements.getNumElements(); i < N; ++i) {
667 DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter);
668 DIDescriptor Ty = Elements.getElement(i);
669 AddType(DW_Unit, Arg, DIType(Ty.getGV()));
670 Buffer.AddChild(Arg);
674 case dwarf::DW_TAG_structure_type:
675 case dwarf::DW_TAG_union_type:
676 case dwarf::DW_TAG_class_type: {
677 // Add elements to structure type.
678 DIArray Elements = CTy.getTypeArray();
680 // A forward struct declared type may not have elements available.
681 if (Elements.isNull())
684 // Add elements to structure type.
685 for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
686 DIDescriptor Element = Elements.getElement(i);
688 if (Element.getTag() == dwarf::DW_TAG_subprogram)
689 ElemDie = CreateSubprogramDIE(DW_Unit,
690 DISubprogram(Element.getGV()));
691 else if (Element.getTag() == dwarf::DW_TAG_variable) // ??
692 ElemDie = CreateGlobalVariableDIE(DW_Unit,
693 DIGlobalVariable(Element.getGV()));
695 ElemDie = CreateMemberDIE(DW_Unit,
696 DIDerivedType(Element.getGV()));
697 Buffer.AddChild(ElemDie);
700 // FIXME: We'd like an API to register additional attributes for the
701 // frontend to use while synthesizing, and then we'd use that api in clang
703 if (Name == "__block_literal_generic")
704 AddUInt(&Buffer, dwarf::DW_AT_APPLE_block, dwarf::DW_FORM_flag, 1);
706 unsigned RLang = CTy.getRunTimeLang();
708 AddUInt(&Buffer, dwarf::DW_AT_APPLE_runtime_class,
709 dwarf::DW_FORM_data1, RLang);
716 // Add name if not anonymous or intermediate type.
718 AddString(&Buffer, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
720 if (Tag == dwarf::DW_TAG_enumeration_type ||
721 Tag == dwarf::DW_TAG_structure_type || Tag == dwarf::DW_TAG_union_type) {
722 // Add size if non-zero (derived types might be zero-sized.)
724 AddUInt(&Buffer, dwarf::DW_AT_byte_size, 0, Size);
726 // Add zero size if it is not a forward declaration.
727 if (CTy.isForwardDecl())
728 AddUInt(&Buffer, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1);
730 AddUInt(&Buffer, dwarf::DW_AT_byte_size, 0, 0);
733 // Add source line info if available.
734 if (!CTy.isForwardDecl())
735 AddSourceLine(&Buffer, &CTy);
739 /// ConstructSubrangeDIE - Construct subrange DIE from DISubrange.
740 void DwarfDebug::ConstructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy){
741 int64_t L = SR.getLo();
742 int64_t H = SR.getHi();
743 DIE *DW_Subrange = new DIE(dwarf::DW_TAG_subrange_type);
746 AddDIEEntry(DW_Subrange, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IndexTy);
748 AddSInt(DW_Subrange, dwarf::DW_AT_lower_bound, 0, L);
749 AddSInt(DW_Subrange, dwarf::DW_AT_upper_bound, 0, H);
752 Buffer.AddChild(DW_Subrange);
755 /// ConstructArrayTypeDIE - Construct array type DIE from DICompositeType.
756 void DwarfDebug::ConstructArrayTypeDIE(CompileUnit *DW_Unit, DIE &Buffer,
757 DICompositeType *CTy) {
758 Buffer.setTag(dwarf::DW_TAG_array_type);
759 if (CTy->getTag() == dwarf::DW_TAG_vector_type)
760 AddUInt(&Buffer, dwarf::DW_AT_GNU_vector, dwarf::DW_FORM_flag, 1);
762 // Emit derived type.
763 AddType(DW_Unit, &Buffer, CTy->getTypeDerivedFrom());
764 DIArray Elements = CTy->getTypeArray();
766 // Construct an anonymous type for index type.
767 DIE IdxBuffer(dwarf::DW_TAG_base_type);
768 AddUInt(&IdxBuffer, dwarf::DW_AT_byte_size, 0, sizeof(int32_t));
769 AddUInt(&IdxBuffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
770 dwarf::DW_ATE_signed);
771 DIE *IndexTy = DW_Unit->AddDie(IdxBuffer);
773 // Add subranges to array type.
774 for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
775 DIDescriptor Element = Elements.getElement(i);
776 if (Element.getTag() == dwarf::DW_TAG_subrange_type)
777 ConstructSubrangeDIE(Buffer, DISubrange(Element.getGV()), IndexTy);
781 /// ConstructEnumTypeDIE - Construct enum type DIE from DIEnumerator.
782 DIE *DwarfDebug::ConstructEnumTypeDIE(CompileUnit *DW_Unit, DIEnumerator *ETy) {
783 DIE *Enumerator = new DIE(dwarf::DW_TAG_enumerator);
786 AddString(Enumerator, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
787 int64_t Value = ETy->getEnumValue();
788 AddSInt(Enumerator, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, Value);
792 /// CreateGlobalVariableDIE - Create new DIE using GV.
793 DIE *DwarfDebug::CreateGlobalVariableDIE(CompileUnit *DW_Unit,
794 const DIGlobalVariable &GV) {
795 DIE *GVDie = new DIE(dwarf::DW_TAG_variable);
797 GV.getDisplayName(Name);
798 AddString(GVDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
799 std::string LinkageName;
800 GV.getLinkageName(LinkageName);
801 if (!LinkageName.empty())
802 AddString(GVDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string,
804 AddType(DW_Unit, GVDie, GV.getType());
805 if (!GV.isLocalToUnit())
806 AddUInt(GVDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1);
807 AddSourceLine(GVDie, &GV);
811 /// CreateMemberDIE - Create new member DIE.
812 DIE *DwarfDebug::CreateMemberDIE(CompileUnit *DW_Unit, const DIDerivedType &DT){
813 DIE *MemberDie = new DIE(DT.getTag());
817 AddString(MemberDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
819 AddType(DW_Unit, MemberDie, DT.getTypeDerivedFrom());
821 AddSourceLine(MemberDie, &DT);
823 uint64_t Size = DT.getSizeInBits();
824 uint64_t FieldSize = DT.getOriginalTypeSize();
826 if (Size != FieldSize) {
828 AddUInt(MemberDie, dwarf::DW_AT_byte_size, 0, DT.getOriginalTypeSize()>>3);
829 AddUInt(MemberDie, dwarf::DW_AT_bit_size, 0, DT.getSizeInBits());
831 uint64_t Offset = DT.getOffsetInBits();
832 uint64_t FieldOffset = Offset;
833 uint64_t AlignMask = ~(DT.getAlignInBits() - 1);
834 uint64_t HiMark = (Offset + FieldSize) & AlignMask;
835 FieldOffset = (HiMark - FieldSize);
836 Offset -= FieldOffset;
838 // Maybe we need to work from the other end.
839 if (TD->isLittleEndian()) Offset = FieldSize - (Offset + Size);
840 AddUInt(MemberDie, dwarf::DW_AT_bit_offset, 0, Offset);
843 DIEBlock *Block = new DIEBlock();
844 AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
845 AddUInt(Block, 0, dwarf::DW_FORM_udata, DT.getOffsetInBits() >> 3);
846 AddBlock(MemberDie, dwarf::DW_AT_data_member_location, 0, Block);
848 if (DT.isProtected())
849 AddUInt(MemberDie, dwarf::DW_AT_accessibility, 0,
850 dwarf::DW_ACCESS_protected);
851 else if (DT.isPrivate())
852 AddUInt(MemberDie, dwarf::DW_AT_accessibility, 0,
853 dwarf::DW_ACCESS_private);
858 /// CreateSubprogramDIE - Create new DIE using SP.
859 DIE *DwarfDebug::CreateSubprogramDIE(CompileUnit *DW_Unit,
860 const DISubprogram &SP,
863 DIE *SPDie = new DIE(dwarf::DW_TAG_subprogram);
867 AddString(SPDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
869 std::string LinkageName;
870 SP.getLinkageName(LinkageName);
872 if (!LinkageName.empty())
873 AddString(SPDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string,
876 AddSourceLine(SPDie, &SP);
878 DICompositeType SPTy = SP.getType();
879 DIArray Args = SPTy.getTypeArray();
881 // Add prototyped tag, if C or ObjC.
882 unsigned Lang = SP.getCompileUnit().getLanguage();
883 if (Lang == dwarf::DW_LANG_C99 || Lang == dwarf::DW_LANG_C89 ||
884 Lang == dwarf::DW_LANG_ObjC)
885 AddUInt(SPDie, dwarf::DW_AT_prototyped, dwarf::DW_FORM_flag, 1);
888 unsigned SPTag = SPTy.getTag();
889 if (!IsConstructor) {
890 if (Args.isNull() || SPTag != dwarf::DW_TAG_subroutine_type)
891 AddType(DW_Unit, SPDie, SPTy);
893 AddType(DW_Unit, SPDie, DIType(Args.getElement(0).getGV()));
896 if (!SP.isDefinition()) {
897 AddUInt(SPDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1);
899 // Add arguments. Do not add arguments for subprogram definition. They will
900 // be handled through RecordVariable.
901 if (SPTag == dwarf::DW_TAG_subroutine_type)
902 for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
903 DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter);
904 AddType(DW_Unit, Arg, DIType(Args.getElement(i).getGV()));
905 AddUInt(Arg, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1); // ??
906 SPDie->AddChild(Arg);
910 if (!SP.isLocalToUnit() && !IsInlined)
911 AddUInt(SPDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1);
913 // DW_TAG_inlined_subroutine may refer to this DIE.
914 DIE *&Slot = DW_Unit->getDieMapSlotFor(SP.getGV());
919 /// FindCompileUnit - Get the compile unit for the given descriptor.
921 CompileUnit &DwarfDebug::FindCompileUnit(DICompileUnit Unit) const {
922 DenseMap<Value *, CompileUnit *>::const_iterator I =
923 CompileUnitMap.find(Unit.getGV());
924 assert(I != CompileUnitMap.end() && "Missing compile unit.");
928 /// NewDbgScopeVariable - Create a new scope variable.
930 DIE *DwarfDebug::NewDbgScopeVariable(DbgVariable *DV, CompileUnit *Unit) {
931 // Get the descriptor.
932 const DIVariable &VD = DV->getVariable();
934 // Translate tag to proper Dwarf tag. The result variable is dropped for
937 switch (VD.getTag()) {
938 case dwarf::DW_TAG_return_variable:
940 case dwarf::DW_TAG_arg_variable:
941 Tag = dwarf::DW_TAG_formal_parameter;
943 case dwarf::DW_TAG_auto_variable: // fall thru
945 Tag = dwarf::DW_TAG_variable;
949 // Define variable debug information entry.
950 DIE *VariableDie = new DIE(Tag);
953 AddString(VariableDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
955 // Add source line info if available.
956 AddSourceLine(VariableDie, &VD);
958 // Add variable type.
959 AddType(Unit, VariableDie, VD.getType());
961 // Add variable address.
962 if (!DV->isInlinedFnVar()) {
963 // Variables for abstract instances of inlined functions don't get a
965 MachineLocation Location;
966 Location.set(RI->getFrameRegister(*MF),
967 RI->getFrameIndexOffset(*MF, DV->getFrameIndex()));
968 AddAddress(VariableDie, dwarf::DW_AT_location, Location);
974 /// getOrCreateScope - Returns the scope associated with the given descriptor.
976 DbgScope *DwarfDebug::getOrCreateScope(GlobalVariable *V) {
977 DbgScope *&Slot = DbgScopeMap[V];
978 if (Slot) return Slot;
980 DbgScope *Parent = NULL;
983 // Don't create a new scope if we already created one for an inlined function.
984 DenseMap<const GlobalVariable *, DbgScope *>::iterator
985 II = AbstractInstanceRootMap.find(V);
986 if (II != AbstractInstanceRootMap.end())
987 return LexicalScopeStack.back();
989 if (!Block.isNull()) {
990 DIDescriptor ParentDesc = Block.getContext();
992 ParentDesc.isNull() ? NULL : getOrCreateScope(ParentDesc.getGV());
995 Slot = new DbgScope(Parent, DIDescriptor(V));
998 Parent->AddScope(Slot);
1000 // First function is top level function.
1001 FunctionDbgScope = Slot;
1006 /// ConstructDbgScope - Construct the components of a scope.
1008 void DwarfDebug::ConstructDbgScope(DbgScope *ParentScope,
1009 unsigned ParentStartID,
1010 unsigned ParentEndID,
1011 DIE *ParentDie, CompileUnit *Unit) {
1012 // Add variables to scope.
1013 SmallVector<DbgVariable *, 8> &Variables = ParentScope->getVariables();
1014 for (unsigned i = 0, N = Variables.size(); i < N; ++i) {
1015 DIE *VariableDie = NewDbgScopeVariable(Variables[i], Unit);
1016 if (VariableDie) ParentDie->AddChild(VariableDie);
1019 // Add concrete instances to scope.
1020 SmallVector<DbgConcreteScope *, 8> &ConcreteInsts =
1021 ParentScope->getConcreteInsts();
1022 for (unsigned i = 0, N = ConcreteInsts.size(); i < N; ++i) {
1023 DbgConcreteScope *ConcreteInst = ConcreteInsts[i];
1024 DIE *Die = ConcreteInst->getDie();
1026 unsigned StartID = ConcreteInst->getStartLabelID();
1027 unsigned EndID = ConcreteInst->getEndLabelID();
1029 // Add the scope bounds.
1031 AddLabel(Die, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
1032 DWLabel("label", StartID));
1034 AddLabel(Die, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
1035 DWLabel("func_begin", SubprogramCount));
1038 AddLabel(Die, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
1039 DWLabel("label", EndID));
1041 AddLabel(Die, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
1042 DWLabel("func_end", SubprogramCount));
1044 ParentDie->AddChild(Die);
1047 // Add nested scopes.
1048 SmallVector<DbgScope *, 4> &Scopes = ParentScope->getScopes();
1049 for (unsigned j = 0, M = Scopes.size(); j < M; ++j) {
1050 // Define the Scope debug information entry.
1051 DbgScope *Scope = Scopes[j];
1053 unsigned StartID = MMI->MappedLabel(Scope->getStartLabelID());
1054 unsigned EndID = MMI->MappedLabel(Scope->getEndLabelID());
1056 // Ignore empty scopes.
1057 if (StartID == EndID && StartID != 0) continue;
1059 // Do not ignore inlined scopes even if they don't have any variables or
1061 if (Scope->getScopes().empty() && Scope->getVariables().empty() &&
1062 Scope->getConcreteInsts().empty())
1065 if (StartID == ParentStartID && EndID == ParentEndID) {
1066 // Just add stuff to the parent scope.
1067 ConstructDbgScope(Scope, ParentStartID, ParentEndID, ParentDie, Unit);
1069 DIE *ScopeDie = new DIE(dwarf::DW_TAG_lexical_block);
1071 // Add the scope bounds.
1073 AddLabel(ScopeDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
1074 DWLabel("label", StartID));
1076 AddLabel(ScopeDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
1077 DWLabel("func_begin", SubprogramCount));
1080 AddLabel(ScopeDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
1081 DWLabel("label", EndID));
1083 AddLabel(ScopeDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
1084 DWLabel("func_end", SubprogramCount));
1086 // Add the scope's contents.
1087 ConstructDbgScope(Scope, StartID, EndID, ScopeDie, Unit);
1088 ParentDie->AddChild(ScopeDie);
1093 /// ConstructFunctionDbgScope - Construct the scope for the subprogram.
1095 void DwarfDebug::ConstructFunctionDbgScope(DbgScope *RootScope) {
1096 // Exit if there is no root scope.
1097 if (!RootScope) return;
1098 DIDescriptor Desc = RootScope->getDesc();
1102 // Get the subprogram debug information entry.
1103 DISubprogram SPD(Desc.getGV());
1105 // Get the compile unit context.
1106 CompileUnit *Unit = MainCU;
1108 Unit = &FindCompileUnit(SPD.getCompileUnit());
1110 // Get the subprogram die.
1111 DIE *SPDie = Unit->getDieMapSlotFor(SPD.getGV());
1112 assert(SPDie && "Missing subprogram descriptor");
1114 // Add the function bounds.
1115 AddLabel(SPDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
1116 DWLabel("func_begin", SubprogramCount));
1117 AddLabel(SPDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
1118 DWLabel("func_end", SubprogramCount));
1119 MachineLocation Location(RI->getFrameRegister(*MF));
1120 AddAddress(SPDie, dwarf::DW_AT_frame_base, Location);
1122 ConstructDbgScope(RootScope, 0, 0, SPDie, Unit);
1125 /// ConstructFunctionDbgScope - Construct the scope for the abstract debug
1128 void DwarfDebug::ConstructAbstractDbgScope(DbgScope *AbsScope) {
1129 // Exit if there is no root scope.
1130 if (!AbsScope) return;
1132 DIDescriptor Desc = AbsScope->getDesc();
1136 // Get the subprogram debug information entry.
1137 DISubprogram SPD(Desc.getGV());
1139 // Get the compile unit context.
1140 CompileUnit *Unit = MainCU;
1142 Unit = &FindCompileUnit(SPD.getCompileUnit());
1144 // Get the subprogram die.
1145 DIE *SPDie = Unit->getDieMapSlotFor(SPD.getGV());
1146 assert(SPDie && "Missing subprogram descriptor");
1148 ConstructDbgScope(AbsScope, 0, 0, SPDie, Unit);
1151 /// ConstructDefaultDbgScope - Construct a default scope for the subprogram.
1153 void DwarfDebug::ConstructDefaultDbgScope(MachineFunction *MF) {
1154 const char *FnName = MF->getFunction()->getNameStart();
1156 StringMap<DIE*> &Globals = MainCU->getGlobals();
1157 StringMap<DIE*>::iterator GI = Globals.find(FnName);
1158 if (GI != Globals.end()) {
1159 DIE *SPDie = GI->second;
1161 // Add the function bounds.
1162 AddLabel(SPDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
1163 DWLabel("func_begin", SubprogramCount));
1164 AddLabel(SPDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
1165 DWLabel("func_end", SubprogramCount));
1167 MachineLocation Location(RI->getFrameRegister(*MF));
1168 AddAddress(SPDie, dwarf::DW_AT_frame_base, Location);
1172 for (unsigned i = 0, e = CompileUnits.size(); i != e; ++i) {
1173 CompileUnit *Unit = CompileUnits[i];
1174 StringMap<DIE*> &Globals = Unit->getGlobals();
1175 StringMap<DIE*>::iterator GI = Globals.find(FnName);
1176 if (GI != Globals.end()) {
1177 DIE *SPDie = GI->second;
1179 // Add the function bounds.
1180 AddLabel(SPDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
1181 DWLabel("func_begin", SubprogramCount));
1182 AddLabel(SPDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
1183 DWLabel("func_end", SubprogramCount));
1185 MachineLocation Location(RI->getFrameRegister(*MF));
1186 AddAddress(SPDie, dwarf::DW_AT_frame_base, Location);
1193 // FIXME: This is causing an abort because C++ mangled names are compared with
1194 // their unmangled counterparts. See PR2885. Don't do this assert.
1195 assert(0 && "Couldn't find DIE for machine function!");
1199 /// GetOrCreateSourceID - Look up the source id with the given directory and
1200 /// source file names. If none currently exists, create a new id and insert it
1201 /// in the SourceIds map. This can update DirectoryNames and SourceFileNames
1203 unsigned DwarfDebug::GetOrCreateSourceID(const std::string &DirName,
1204 const std::string &FileName) {
1206 StringMap<unsigned>::iterator DI = DirectoryIdMap.find(DirName);
1207 if (DI != DirectoryIdMap.end()) {
1208 DId = DI->getValue();
1210 DId = DirectoryNames.size() + 1;
1211 DirectoryIdMap[DirName] = DId;
1212 DirectoryNames.push_back(DirName);
1216 StringMap<unsigned>::iterator FI = SourceFileIdMap.find(FileName);
1217 if (FI != SourceFileIdMap.end()) {
1218 FId = FI->getValue();
1220 FId = SourceFileNames.size() + 1;
1221 SourceFileIdMap[FileName] = FId;
1222 SourceFileNames.push_back(FileName);
1225 DenseMap<std::pair<unsigned, unsigned>, unsigned>::iterator SI =
1226 SourceIdMap.find(std::make_pair(DId, FId));
1227 if (SI != SourceIdMap.end())
1230 unsigned SrcId = SourceIds.size() + 1; // DW_AT_decl_file cannot be 0.
1231 SourceIdMap[std::make_pair(DId, FId)] = SrcId;
1232 SourceIds.push_back(std::make_pair(DId, FId));
1237 void DwarfDebug::ConstructCompileUnit(GlobalVariable *GV) {
1238 DICompileUnit DIUnit(GV);
1239 std::string Dir, FN, Prod;
1240 unsigned ID = GetOrCreateSourceID(DIUnit.getDirectory(Dir),
1241 DIUnit.getFilename(FN));
1243 DIE *Die = new DIE(dwarf::DW_TAG_compile_unit);
1244 AddSectionOffset(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4,
1245 DWLabel("section_line", 0), DWLabel("section_line", 0),
1247 AddString(Die, dwarf::DW_AT_producer, dwarf::DW_FORM_string,
1248 DIUnit.getProducer(Prod));
1249 AddUInt(Die, dwarf::DW_AT_language, dwarf::DW_FORM_data1,
1250 DIUnit.getLanguage());
1251 AddString(Die, dwarf::DW_AT_name, dwarf::DW_FORM_string, FN);
1254 AddString(Die, dwarf::DW_AT_comp_dir, dwarf::DW_FORM_string, Dir);
1255 if (DIUnit.isOptimized())
1256 AddUInt(Die, dwarf::DW_AT_APPLE_optimized, dwarf::DW_FORM_flag, 1);
1259 DIUnit.getFlags(Flags);
1261 AddString(Die, dwarf::DW_AT_APPLE_flags, dwarf::DW_FORM_string, Flags);
1263 unsigned RVer = DIUnit.getRunTimeVersion();
1265 AddUInt(Die, dwarf::DW_AT_APPLE_major_runtime_vers,
1266 dwarf::DW_FORM_data1, RVer);
1268 CompileUnit *Unit = new CompileUnit(ID, Die);
1269 if (DIUnit.isMain()) {
1270 assert(!MainCU && "Multiple main compile units are found!");
1274 CompileUnitMap[DIUnit.getGV()] = Unit;
1275 CompileUnits.push_back(Unit);
1278 /// ConstructCompileUnits - Create a compile unit DIEs.
1279 void DwarfDebug::ConstructCompileUnits() {
1280 GlobalVariable *Root = M->getGlobalVariable("llvm.dbg.compile_units");
1283 assert(Root->hasLinkOnceLinkage() && Root->hasOneUse() &&
1284 "Malformed compile unit descriptor anchor type");
1285 Constant *RootC = cast<Constant>(*Root->use_begin());
1286 assert(RootC->hasNUsesOrMore(1) &&
1287 "Malformed compile unit descriptor anchor type");
1289 for (Value::use_iterator UI = RootC->use_begin(), UE = Root->use_end();
1291 for (Value::use_iterator UUI = UI->use_begin(), UUE = UI->use_end();
1292 UUI != UUE; ++UUI) {
1293 GlobalVariable *GV = cast<GlobalVariable>(*UUI);
1294 ConstructCompileUnit(GV);
1298 bool DwarfDebug::ConstructGlobalVariableDIE(GlobalVariable *GV) {
1299 DIGlobalVariable DI_GV(GV);
1300 CompileUnit *DW_Unit = MainCU;
1302 DW_Unit = &FindCompileUnit(DI_GV.getCompileUnit());
1304 // Check for pre-existence.
1305 DIE *&Slot = DW_Unit->getDieMapSlotFor(DI_GV.getGV());
1309 DIE *VariableDie = CreateGlobalVariableDIE(DW_Unit, DI_GV);
1312 DIEBlock *Block = new DIEBlock();
1313 AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
1315 AddObjectLabel(Block, 0, dwarf::DW_FORM_udata,
1316 Asm->getGlobalLinkName(DI_GV.getGlobal(), GLN));
1317 AddBlock(VariableDie, dwarf::DW_AT_location, 0, Block);
1322 // Add to context owner.
1323 DW_Unit->getDie()->AddChild(VariableDie);
1325 // Expose as global. FIXME - need to check external flag.
1327 DW_Unit->AddGlobal(DI_GV.getName(Name), VariableDie);
1331 /// ConstructGlobalVariableDIEs - Create DIEs for each of the externally visible
1332 /// global variables. Return true if at least one global DIE is created.
1333 bool DwarfDebug::ConstructGlobalVariableDIEs() {
1334 GlobalVariable *Root = M->getGlobalVariable("llvm.dbg.global_variables");
1338 assert(Root->hasLinkOnceLinkage() && Root->hasOneUse() &&
1339 "Malformed global variable descriptor anchor type");
1340 Constant *RootC = cast<Constant>(*Root->use_begin());
1341 assert(RootC->hasNUsesOrMore(1) &&
1342 "Malformed global variable descriptor anchor type");
1344 bool Result = false;
1345 for (Value::use_iterator UI = RootC->use_begin(), UE = Root->use_end();
1347 for (Value::use_iterator UUI = UI->use_begin(), UUE = UI->use_end();
1349 Result |= ConstructGlobalVariableDIE(cast<GlobalVariable>(*UUI));
1354 bool DwarfDebug::ConstructSubprogram(GlobalVariable *GV) {
1355 DISubprogram SP(GV);
1356 CompileUnit *Unit = MainCU;
1358 Unit = &FindCompileUnit(SP.getCompileUnit());
1360 // Check for pre-existence.
1361 DIE *&Slot = Unit->getDieMapSlotFor(GV);
1365 if (!SP.isDefinition())
1366 // This is a method declaration which will be handled while constructing
1370 DIE *SubprogramDie = CreateSubprogramDIE(Unit, SP);
1373 Slot = SubprogramDie;
1375 // Add to context owner.
1376 Unit->getDie()->AddChild(SubprogramDie);
1378 // Expose as global.
1380 Unit->AddGlobal(SP.getName(Name), SubprogramDie);
1384 /// ConstructSubprograms - Create DIEs for each of the externally visible
1385 /// subprograms. Return true if at least one subprogram DIE is created.
1386 bool DwarfDebug::ConstructSubprograms() {
1387 GlobalVariable *Root = M->getGlobalVariable("llvm.dbg.subprograms");
1391 assert(Root->hasLinkOnceLinkage() && Root->hasOneUse() &&
1392 "Malformed subprogram descriptor anchor type");
1393 Constant *RootC = cast<Constant>(*Root->use_begin());
1394 assert(RootC->hasNUsesOrMore(1) &&
1395 "Malformed subprogram descriptor anchor type");
1397 bool Result = false;
1398 for (Value::use_iterator UI = RootC->use_begin(), UE = Root->use_end();
1400 for (Value::use_iterator UUI = UI->use_begin(), UUE = UI->use_end();
1402 Result |= ConstructSubprogram(cast<GlobalVariable>(*UUI));
1407 /// SetDebugInfo - Create global DIEs and emit initial debug info sections.
1408 /// This is inovked by the target AsmPrinter.
1409 void DwarfDebug::SetDebugInfo(MachineModuleInfo *mmi) {
1410 if (TimePassesIsEnabled)
1411 DebugTimer->startTimer();
1413 // Create all the compile unit DIEs.
1414 ConstructCompileUnits();
1416 if (CompileUnits.empty()) {
1417 if (TimePassesIsEnabled)
1418 DebugTimer->stopTimer();
1423 // Create DIEs for each of the externally visible global variables.
1424 bool globalDIEs = ConstructGlobalVariableDIEs();
1426 // Create DIEs for each of the externally visible subprograms.
1427 bool subprogramDIEs = ConstructSubprograms();
1429 // If there is not any debug info available for any global variables and any
1430 // subprograms then there is not any debug info to emit.
1431 if (!globalDIEs && !subprogramDIEs) {
1432 if (TimePassesIsEnabled)
1433 DebugTimer->stopTimer();
1440 MMI->setDebugInfoAvailability(true);
1442 // Prime section data.
1443 SectionMap.insert(TAI->getTextSection());
1445 // Print out .file directives to specify files for .loc directives. These are
1446 // printed out early so that they precede any .loc directives.
1447 if (TAI->hasDotLocAndDotFile()) {
1448 for (unsigned i = 1, e = getNumSourceIds()+1; i != e; ++i) {
1449 // Remember source id starts at 1.
1450 std::pair<unsigned, unsigned> Id = getSourceDirectoryAndFileIds(i);
1451 sys::Path FullPath(getSourceDirectoryName(Id.first));
1453 FullPath.appendComponent(getSourceFileName(Id.second));
1454 assert(AppendOk && "Could not append filename to directory!");
1456 Asm->EmitFile(i, FullPath.toString());
1461 // Emit initial sections
1464 if (TimePassesIsEnabled)
1465 DebugTimer->stopTimer();
1468 /// EndModule - Emit all Dwarf sections that should come after the content.
1470 void DwarfDebug::EndModule() {
1471 if (!ShouldEmitDwarfDebug())
1474 if (TimePassesIsEnabled)
1475 DebugTimer->startTimer();
1477 // Standard sections final addresses.
1478 Asm->SwitchToSection(TAI->getTextSection());
1479 EmitLabel("text_end", 0);
1480 Asm->SwitchToSection(TAI->getDataSection());
1481 EmitLabel("data_end", 0);
1483 // End text sections.
1484 for (unsigned i = 1, N = SectionMap.size(); i <= N; ++i) {
1485 Asm->SwitchToSection(SectionMap[i]);
1486 EmitLabel("section_end", i);
1489 // Emit common frame information.
1490 EmitCommonDebugFrame();
1492 // Emit function debug frame information
1493 for (std::vector<FunctionDebugFrameInfo>::iterator I = DebugFrames.begin(),
1494 E = DebugFrames.end(); I != E; ++I)
1495 EmitFunctionDebugFrame(*I);
1497 // Compute DIE offsets and sizes.
1500 // Emit all the DIEs into a debug info section
1503 // Corresponding abbreviations into a abbrev section.
1504 EmitAbbreviations();
1506 // Emit source line correspondence into a debug line section.
1509 // Emit info into a debug pubnames section.
1510 EmitDebugPubNames();
1512 // Emit info into a debug str section.
1515 // Emit info into a debug loc section.
1518 // Emit info into a debug aranges section.
1521 // Emit info into a debug ranges section.
1524 // Emit info into a debug macinfo section.
1527 // Emit inline info.
1528 EmitDebugInlineInfo();
1530 if (TimePassesIsEnabled)
1531 DebugTimer->stopTimer();
1534 /// BeginFunction - Gather pre-function debug information. Assumes being
1535 /// emitted immediately after the function entry point.
1536 void DwarfDebug::BeginFunction(MachineFunction *MF) {
1539 if (!ShouldEmitDwarfDebug()) return;
1541 if (TimePassesIsEnabled)
1542 DebugTimer->startTimer();
1544 // Begin accumulating function debug information.
1545 MMI->BeginFunction(MF);
1547 // Assumes in correct section after the entry point.
1548 EmitLabel("func_begin", ++SubprogramCount);
1550 // Emit label for the implicitly defined dbg.stoppoint at the start of the
1552 DebugLoc FDL = MF->getDefaultDebugLoc();
1553 if (!FDL.isUnknown()) {
1554 DebugLocTuple DLT = MF->getDebugLocTuple(FDL);
1555 unsigned LabelID = RecordSourceLine(DLT.Line, DLT.Col,
1556 DICompileUnit(DLT.CompileUnit));
1557 Asm->printLabel(LabelID);
1560 if (TimePassesIsEnabled)
1561 DebugTimer->stopTimer();
1564 /// EndFunction - Gather and emit post-function debug information.
1566 void DwarfDebug::EndFunction(MachineFunction *MF) {
1567 if (!ShouldEmitDwarfDebug()) return;
1569 if (TimePassesIsEnabled)
1570 DebugTimer->startTimer();
1572 // Define end label for subprogram.
1573 EmitLabel("func_end", SubprogramCount);
1575 // Get function line info.
1576 if (!Lines.empty()) {
1577 // Get section line info.
1578 unsigned ID = SectionMap.insert(Asm->CurrentSection_);
1579 if (SectionSourceLines.size() < ID) SectionSourceLines.resize(ID);
1580 std::vector<SrcLineInfo> &SectionLineInfos = SectionSourceLines[ID-1];
1581 // Append the function info to section info.
1582 SectionLineInfos.insert(SectionLineInfos.end(),
1583 Lines.begin(), Lines.end());
1586 // Construct the DbgScope for abstract instances.
1587 for (SmallVector<DbgScope *, 32>::iterator
1588 I = AbstractInstanceRootList.begin(),
1589 E = AbstractInstanceRootList.end(); I != E; ++I)
1590 ConstructAbstractDbgScope(*I);
1592 // Construct scopes for subprogram.
1593 if (FunctionDbgScope)
1594 ConstructFunctionDbgScope(FunctionDbgScope);
1596 // FIXME: This is wrong. We are essentially getting past a problem with
1597 // debug information not being able to handle unreachable blocks that have
1598 // debug information in them. In particular, those unreachable blocks that
1599 // have "region end" info in them. That situation results in the "root
1600 // scope" not being created. If that's the case, then emit a "default"
1601 // scope, i.e., one that encompasses the whole function. This isn't
1602 // desirable. And a better way of handling this (and all of the debugging
1603 // information) needs to be explored.
1604 ConstructDefaultDbgScope(MF);
1606 DebugFrames.push_back(FunctionDebugFrameInfo(SubprogramCount,
1607 MMI->getFrameMoves()));
1610 if (FunctionDbgScope) {
1611 delete FunctionDbgScope;
1612 DbgScopeMap.clear();
1613 DbgAbstractScopeMap.clear();
1614 DbgConcreteScopeMap.clear();
1615 InlinedVariableScopes.clear();
1616 FunctionDbgScope = NULL;
1617 LexicalScopeStack.clear();
1618 AbstractInstanceRootList.clear();
1623 if (TimePassesIsEnabled)
1624 DebugTimer->stopTimer();
1627 /// RecordSourceLine - Records location information and associates it with a
1628 /// label. Returns a unique label ID used to generate a label and provide
1629 /// correspondence to the source line list.
1630 unsigned DwarfDebug::RecordSourceLine(Value *V, unsigned Line, unsigned Col) {
1631 if (TimePassesIsEnabled)
1632 DebugTimer->startTimer();
1634 CompileUnit *Unit = CompileUnitMap[V];
1635 assert(Unit && "Unable to find CompileUnit");
1636 unsigned ID = MMI->NextLabelID();
1637 Lines.push_back(SrcLineInfo(Line, Col, Unit->getID(), ID));
1639 if (TimePassesIsEnabled)
1640 DebugTimer->stopTimer();
1645 /// RecordSourceLine - Records location information and associates it with a
1646 /// label. Returns a unique label ID used to generate a label and provide
1647 /// correspondence to the source line list.
1648 unsigned DwarfDebug::RecordSourceLine(unsigned Line, unsigned Col,
1650 if (TimePassesIsEnabled)
1651 DebugTimer->startTimer();
1653 std::string Dir, Fn;
1654 unsigned Src = GetOrCreateSourceID(CU.getDirectory(Dir),
1655 CU.getFilename(Fn));
1656 unsigned ID = MMI->NextLabelID();
1657 Lines.push_back(SrcLineInfo(Line, Col, Src, ID));
1659 if (TimePassesIsEnabled)
1660 DebugTimer->stopTimer();
1665 /// getOrCreateSourceID - Public version of GetOrCreateSourceID. This can be
1666 /// timed. Look up the source id with the given directory and source file
1667 /// names. If none currently exists, create a new id and insert it in the
1668 /// SourceIds map. This can update DirectoryNames and SourceFileNames maps as
1670 unsigned DwarfDebug::getOrCreateSourceID(const std::string &DirName,
1671 const std::string &FileName) {
1672 if (TimePassesIsEnabled)
1673 DebugTimer->startTimer();
1675 unsigned SrcId = GetOrCreateSourceID(DirName, FileName);
1677 if (TimePassesIsEnabled)
1678 DebugTimer->stopTimer();
1683 /// RecordRegionStart - Indicate the start of a region.
1684 unsigned DwarfDebug::RecordRegionStart(GlobalVariable *V) {
1685 if (TimePassesIsEnabled)
1686 DebugTimer->startTimer();
1688 DbgScope *Scope = getOrCreateScope(V);
1689 unsigned ID = MMI->NextLabelID();
1690 if (!Scope->getStartLabelID()) Scope->setStartLabelID(ID);
1691 LexicalScopeStack.push_back(Scope);
1693 if (TimePassesIsEnabled)
1694 DebugTimer->stopTimer();
1699 /// RecordRegionEnd - Indicate the end of a region.
1700 unsigned DwarfDebug::RecordRegionEnd(GlobalVariable *V) {
1701 if (TimePassesIsEnabled)
1702 DebugTimer->startTimer();
1704 DbgScope *Scope = getOrCreateScope(V);
1705 unsigned ID = MMI->NextLabelID();
1706 Scope->setEndLabelID(ID);
1707 if (LexicalScopeStack.size() != 0)
1708 LexicalScopeStack.pop_back();
1710 if (TimePassesIsEnabled)
1711 DebugTimer->stopTimer();
1716 /// RecordVariable - Indicate the declaration of a local variable.
1717 void DwarfDebug::RecordVariable(GlobalVariable *GV, unsigned FrameIndex,
1718 const MachineInstr *MI) {
1719 if (TimePassesIsEnabled)
1720 DebugTimer->startTimer();
1722 DIDescriptor Desc(GV);
1723 DbgScope *Scope = NULL;
1724 bool InlinedFnVar = false;
1726 if (Desc.getTag() == dwarf::DW_TAG_variable) {
1727 // GV is a global variable.
1728 DIGlobalVariable DG(GV);
1729 Scope = getOrCreateScope(DG.getContext().getGV());
1731 DenseMap<const MachineInstr *, DbgScope *>::iterator
1732 SI = InlinedVariableScopes.find(MI);
1734 if (SI != InlinedVariableScopes.end()) {
1735 // or GV is an inlined local variable.
1739 GlobalVariable *V = DV.getContext().getGV();
1741 // FIXME: The code that checks for the inlined local variable is a hack!
1742 DenseMap<const GlobalVariable *, DbgScope *>::iterator
1743 AI = AbstractInstanceRootMap.find(V);
1745 if (AI != AbstractInstanceRootMap.end()) {
1746 // This method is called each time a DECLARE node is encountered. For an
1747 // inlined function, this could be many, many times. We don't want to
1748 // re-add variables to that DIE for each time. We just want to add them
1749 // once. Check to make sure that we haven't added them already.
1750 DenseMap<const GlobalVariable *,
1751 SmallSet<const GlobalVariable *, 32> >::iterator
1752 IP = InlinedParamMap.find(V);
1754 if (IP != InlinedParamMap.end() && IP->second.count(GV) > 0) {
1755 if (TimePassesIsEnabled)
1756 DebugTimer->stopTimer();
1760 // or GV is an inlined local variable.
1762 InlinedParamMap[V].insert(GV);
1763 InlinedFnVar = true;
1765 // or GV is a local variable.
1766 Scope = getOrCreateScope(V);
1771 assert(Scope && "Unable to find the variable's scope");
1772 DbgVariable *DV = new DbgVariable(DIVariable(GV), FrameIndex, InlinedFnVar);
1773 Scope->AddVariable(DV);
1775 if (TimePassesIsEnabled)
1776 DebugTimer->stopTimer();
1779 //// RecordInlinedFnStart - Indicate the start of inlined subroutine.
1780 unsigned DwarfDebug::RecordInlinedFnStart(DISubprogram &SP, DICompileUnit CU,
1781 unsigned Line, unsigned Col) {
1782 unsigned LabelID = MMI->NextLabelID();
1784 if (!TAI->doesDwarfUsesInlineInfoSection())
1787 if (TimePassesIsEnabled)
1788 DebugTimer->startTimer();
1790 GlobalVariable *GV = SP.getGV();
1791 DenseMap<const GlobalVariable *, DbgScope *>::iterator
1792 II = AbstractInstanceRootMap.find(GV);
1794 if (II == AbstractInstanceRootMap.end()) {
1795 // Create an abstract instance entry for this inlined function if it doesn't
1797 DbgScope *Scope = new DbgScope(NULL, DIDescriptor(GV));
1799 // Get the compile unit context.
1800 CompileUnit *Unit = &FindCompileUnit(SP.getCompileUnit());
1801 DIE *SPDie = Unit->getDieMapSlotFor(GV);
1803 SPDie = CreateSubprogramDIE(Unit, SP, false, true);
1805 // Mark as being inlined. This makes this subprogram entry an abstract
1807 // FIXME: Our debugger doesn't care about the value of DW_AT_inline, only
1808 // that it's defined. That probably won't change in the future. However,
1809 // this could be more elegant.
1810 AddUInt(SPDie, dwarf::DW_AT_inline, 0, dwarf::DW_INL_declared_not_inlined);
1812 // Keep track of the abstract scope for this function.
1813 DbgAbstractScopeMap[GV] = Scope;
1815 AbstractInstanceRootMap[GV] = Scope;
1816 AbstractInstanceRootList.push_back(Scope);
1819 // Create a concrete inlined instance for this inlined function.
1820 DbgConcreteScope *ConcreteScope = new DbgConcreteScope(DIDescriptor(GV));
1821 DIE *ScopeDie = new DIE(dwarf::DW_TAG_inlined_subroutine);
1822 CompileUnit *Unit = &FindCompileUnit(SP.getCompileUnit());
1823 ScopeDie->setAbstractCompileUnit(Unit);
1825 DIE *Origin = Unit->getDieMapSlotFor(GV);
1826 AddDIEEntry(ScopeDie, dwarf::DW_AT_abstract_origin,
1827 dwarf::DW_FORM_ref4, Origin);
1828 AddUInt(ScopeDie, dwarf::DW_AT_call_file, 0, Unit->getID());
1829 AddUInt(ScopeDie, dwarf::DW_AT_call_line, 0, Line);
1830 AddUInt(ScopeDie, dwarf::DW_AT_call_column, 0, Col);
1832 ConcreteScope->setDie(ScopeDie);
1833 ConcreteScope->setStartLabelID(LabelID);
1834 MMI->RecordUsedDbgLabel(LabelID);
1836 LexicalScopeStack.back()->AddConcreteInst(ConcreteScope);
1838 // Keep track of the concrete scope that's inlined into this function.
1839 DenseMap<GlobalVariable *, SmallVector<DbgScope *, 8> >::iterator
1840 SI = DbgConcreteScopeMap.find(GV);
1842 if (SI == DbgConcreteScopeMap.end())
1843 DbgConcreteScopeMap[GV].push_back(ConcreteScope);
1845 SI->second.push_back(ConcreteScope);
1847 // Track the start label for this inlined function.
1848 DenseMap<GlobalVariable *, SmallVector<unsigned, 4> >::iterator
1849 I = InlineInfo.find(GV);
1851 if (I == InlineInfo.end())
1852 InlineInfo[GV].push_back(LabelID);
1854 I->second.push_back(LabelID);
1856 if (TimePassesIsEnabled)
1857 DebugTimer->stopTimer();
1862 /// RecordInlinedFnEnd - Indicate the end of inlined subroutine.
1863 unsigned DwarfDebug::RecordInlinedFnEnd(DISubprogram &SP) {
1864 if (!TAI->doesDwarfUsesInlineInfoSection())
1867 if (TimePassesIsEnabled)
1868 DebugTimer->startTimer();
1870 GlobalVariable *GV = SP.getGV();
1871 DenseMap<GlobalVariable *, SmallVector<DbgScope *, 8> >::iterator
1872 I = DbgConcreteScopeMap.find(GV);
1874 if (I == DbgConcreteScopeMap.end()) {
1875 // FIXME: Can this situation actually happen? And if so, should it?
1876 if (TimePassesIsEnabled)
1877 DebugTimer->stopTimer();
1882 SmallVector<DbgScope *, 8> &Scopes = I->second;
1883 assert(!Scopes.empty() && "We should have at least one debug scope!");
1884 DbgScope *Scope = Scopes.back(); Scopes.pop_back();
1885 unsigned ID = MMI->NextLabelID();
1886 MMI->RecordUsedDbgLabel(ID);
1887 Scope->setEndLabelID(ID);
1889 if (TimePassesIsEnabled)
1890 DebugTimer->stopTimer();
1895 /// RecordVariableScope - Record scope for the variable declared by
1896 /// DeclareMI. DeclareMI must describe TargetInstrInfo::DECLARE. Record scopes
1897 /// for only inlined subroutine variables. Other variables's scopes are
1898 /// determined during RecordVariable().
1899 void DwarfDebug::RecordVariableScope(DIVariable &DV,
1900 const MachineInstr *DeclareMI) {
1901 if (TimePassesIsEnabled)
1902 DebugTimer->startTimer();
1904 DISubprogram SP(DV.getContext().getGV());
1907 if (TimePassesIsEnabled)
1908 DebugTimer->stopTimer();
1913 DenseMap<GlobalVariable *, DbgScope *>::iterator
1914 I = DbgAbstractScopeMap.find(SP.getGV());
1915 if (I != DbgAbstractScopeMap.end())
1916 InlinedVariableScopes[DeclareMI] = I->second;
1918 if (TimePassesIsEnabled)
1919 DebugTimer->stopTimer();
1922 /// SizeAndOffsetDie - Compute the size and offset of a DIE.
1924 unsigned DwarfDebug::SizeAndOffsetDie(DIE *Die, unsigned Offset, bool Last) {
1925 // Get the children.
1926 const std::vector<DIE *> &Children = Die->getChildren();
1928 // If not last sibling and has children then add sibling offset attribute.
1929 if (!Last && !Children.empty()) Die->AddSiblingOffset();
1931 // Record the abbreviation.
1932 AssignAbbrevNumber(Die->getAbbrev());
1934 // Get the abbreviation for this DIE.
1935 unsigned AbbrevNumber = Die->getAbbrevNumber();
1936 const DIEAbbrev *Abbrev = Abbreviations[AbbrevNumber - 1];
1939 Die->setOffset(Offset);
1941 // Start the size with the size of abbreviation code.
1942 Offset += TargetAsmInfo::getULEB128Size(AbbrevNumber);
1944 const SmallVector<DIEValue*, 32> &Values = Die->getValues();
1945 const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev->getData();
1947 // Size the DIE attribute values.
1948 for (unsigned i = 0, N = Values.size(); i < N; ++i)
1949 // Size attribute value.
1950 Offset += Values[i]->SizeOf(TD, AbbrevData[i].getForm());
1952 // Size the DIE children if any.
1953 if (!Children.empty()) {
1954 assert(Abbrev->getChildrenFlag() == dwarf::DW_CHILDREN_yes &&
1955 "Children flag not set");
1957 for (unsigned j = 0, M = Children.size(); j < M; ++j)
1958 Offset = SizeAndOffsetDie(Children[j], Offset, (j + 1) == M);
1960 // End of children marker.
1961 Offset += sizeof(int8_t);
1964 Die->setSize(Offset - Die->getOffset());
1968 /// SizeAndOffsets - Compute the size and offset of all the DIEs.
1970 void DwarfDebug::SizeAndOffsets() {
1971 // Compute size of compile unit header.
1972 static unsigned Offset =
1973 sizeof(int32_t) + // Length of Compilation Unit Info
1974 sizeof(int16_t) + // DWARF version number
1975 sizeof(int32_t) + // Offset Into Abbrev. Section
1976 sizeof(int8_t); // Pointer Size (in bytes)
1978 // Process base compile unit.
1980 SizeAndOffsetDie(MainCU->getDie(), Offset, true);
1981 CompileUnitOffsets[MainCU] = 0;
1985 // Process all compile units.
1986 unsigned PrevOffset = 0;
1988 for (unsigned i = 0, e = CompileUnits.size(); i != e; ++i) {
1989 CompileUnit *Unit = CompileUnits[i];
1990 CompileUnitOffsets[Unit] = PrevOffset;
1991 PrevOffset += SizeAndOffsetDie(Unit->getDie(), Offset, true)
1992 + sizeof(int32_t); // FIXME - extra pad for gdb bug.
1996 /// EmitInitial - Emit initial Dwarf declarations. This is necessary for cc
1997 /// tools to recognize the object file contains Dwarf information.
1998 void DwarfDebug::EmitInitial() {
1999 // Check to see if we already emitted intial headers.
2000 if (didInitial) return;
2003 // Dwarf sections base addresses.
2004 if (TAI->doesDwarfRequireFrameSection()) {
2005 Asm->SwitchToDataSection(TAI->getDwarfFrameSection());
2006 EmitLabel("section_debug_frame", 0);
2009 Asm->SwitchToDataSection(TAI->getDwarfInfoSection());
2010 EmitLabel("section_info", 0);
2011 Asm->SwitchToDataSection(TAI->getDwarfAbbrevSection());
2012 EmitLabel("section_abbrev", 0);
2013 Asm->SwitchToDataSection(TAI->getDwarfARangesSection());
2014 EmitLabel("section_aranges", 0);
2016 if (TAI->doesSupportMacInfoSection()) {
2017 Asm->SwitchToDataSection(TAI->getDwarfMacInfoSection());
2018 EmitLabel("section_macinfo", 0);
2021 Asm->SwitchToDataSection(TAI->getDwarfLineSection());
2022 EmitLabel("section_line", 0);
2023 Asm->SwitchToDataSection(TAI->getDwarfLocSection());
2024 EmitLabel("section_loc", 0);
2025 Asm->SwitchToDataSection(TAI->getDwarfPubNamesSection());
2026 EmitLabel("section_pubnames", 0);
2027 Asm->SwitchToDataSection(TAI->getDwarfStrSection());
2028 EmitLabel("section_str", 0);
2029 Asm->SwitchToDataSection(TAI->getDwarfRangesSection());
2030 EmitLabel("section_ranges", 0);
2032 Asm->SwitchToSection(TAI->getTextSection());
2033 EmitLabel("text_begin", 0);
2034 Asm->SwitchToSection(TAI->getDataSection());
2035 EmitLabel("data_begin", 0);
2038 /// EmitDIE - Recusively Emits a debug information entry.
2040 void DwarfDebug::EmitDIE(DIE *Die) {
2041 // Get the abbreviation for this DIE.
2042 unsigned AbbrevNumber = Die->getAbbrevNumber();
2043 const DIEAbbrev *Abbrev = Abbreviations[AbbrevNumber - 1];
2047 // Emit the code (index) for the abbreviation.
2048 Asm->EmitULEB128Bytes(AbbrevNumber);
2050 if (Asm->isVerbose())
2051 Asm->EOL(std::string("Abbrev [" +
2052 utostr(AbbrevNumber) +
2053 "] 0x" + utohexstr(Die->getOffset()) +
2054 ":0x" + utohexstr(Die->getSize()) + " " +
2055 dwarf::TagString(Abbrev->getTag())));
2059 SmallVector<DIEValue*, 32> &Values = Die->getValues();
2060 const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev->getData();
2062 // Emit the DIE attribute values.
2063 for (unsigned i = 0, N = Values.size(); i < N; ++i) {
2064 unsigned Attr = AbbrevData[i].getAttribute();
2065 unsigned Form = AbbrevData[i].getForm();
2066 assert(Form && "Too many attributes for DIE (check abbreviation)");
2069 case dwarf::DW_AT_sibling:
2070 Asm->EmitInt32(Die->SiblingOffset());
2072 case dwarf::DW_AT_abstract_origin: {
2073 DIEEntry *E = cast<DIEEntry>(Values[i]);
2074 DIE *Origin = E->getEntry();
2076 CompileUnitOffsets[Die->getAbstractCompileUnit()] +
2077 Origin->getOffset();
2079 Asm->EmitInt32(Addr);
2083 // Emit an attribute using the defined form.
2084 Values[i]->EmitValue(this, Form);
2088 Asm->EOL(dwarf::AttributeString(Attr));
2091 // Emit the DIE children if any.
2092 if (Abbrev->getChildrenFlag() == dwarf::DW_CHILDREN_yes) {
2093 const std::vector<DIE *> &Children = Die->getChildren();
2095 for (unsigned j = 0, M = Children.size(); j < M; ++j)
2096 EmitDIE(Children[j]);
2098 Asm->EmitInt8(0); Asm->EOL("End Of Children Mark");
2102 /// EmitDebugInfo / EmitDebugInfoPerCU - Emit the debug info section.
2104 void DwarfDebug::EmitDebugInfoPerCU(CompileUnit *Unit) {
2105 DIE *Die = Unit->getDie();
2107 // Emit the compile units header.
2108 EmitLabel("info_begin", Unit->getID());
2110 // Emit size of content not including length itself
2111 unsigned ContentSize = Die->getSize() +
2112 sizeof(int16_t) + // DWARF version number
2113 sizeof(int32_t) + // Offset Into Abbrev. Section
2114 sizeof(int8_t) + // Pointer Size (in bytes)
2115 sizeof(int32_t); // FIXME - extra pad for gdb bug.
2117 Asm->EmitInt32(ContentSize); Asm->EOL("Length of Compilation Unit Info");
2118 Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->EOL("DWARF version number");
2119 EmitSectionOffset("abbrev_begin", "section_abbrev", 0, 0, true, false);
2120 Asm->EOL("Offset Into Abbrev. Section");
2121 Asm->EmitInt8(TD->getPointerSize()); Asm->EOL("Address Size (in bytes)");
2124 // FIXME - extra padding for gdb bug.
2125 Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB");
2126 Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB");
2127 Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB");
2128 Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB");
2129 EmitLabel("info_end", Unit->getID());
2134 void DwarfDebug::EmitDebugInfo() {
2135 // Start debug info section.
2136 Asm->SwitchToDataSection(TAI->getDwarfInfoSection());
2139 EmitDebugInfoPerCU(MainCU);
2143 for (unsigned i = 0, e = CompileUnits.size(); i != e; ++i)
2144 EmitDebugInfoPerCU(CompileUnits[i]);
2147 /// EmitAbbreviations - Emit the abbreviation section.
2149 void DwarfDebug::EmitAbbreviations() const {
2150 // Check to see if it is worth the effort.
2151 if (!Abbreviations.empty()) {
2152 // Start the debug abbrev section.
2153 Asm->SwitchToDataSection(TAI->getDwarfAbbrevSection());
2155 EmitLabel("abbrev_begin", 0);
2157 // For each abbrevation.
2158 for (unsigned i = 0, N = Abbreviations.size(); i < N; ++i) {
2159 // Get abbreviation data
2160 const DIEAbbrev *Abbrev = Abbreviations[i];
2162 // Emit the abbrevations code (base 1 index.)
2163 Asm->EmitULEB128Bytes(Abbrev->getNumber());
2164 Asm->EOL("Abbreviation Code");
2166 // Emit the abbreviations data.
2172 // Mark end of abbreviations.
2173 Asm->EmitULEB128Bytes(0); Asm->EOL("EOM(3)");
2175 EmitLabel("abbrev_end", 0);
2180 /// EmitEndOfLineMatrix - Emit the last address of the section and the end of
2181 /// the line matrix.
2183 void DwarfDebug::EmitEndOfLineMatrix(unsigned SectionEnd) {
2184 // Define last address of section.
2185 Asm->EmitInt8(0); Asm->EOL("Extended Op");
2186 Asm->EmitInt8(TD->getPointerSize() + 1); Asm->EOL("Op size");
2187 Asm->EmitInt8(dwarf::DW_LNE_set_address); Asm->EOL("DW_LNE_set_address");
2188 EmitReference("section_end", SectionEnd); Asm->EOL("Section end label");
2190 // Mark end of matrix.
2191 Asm->EmitInt8(0); Asm->EOL("DW_LNE_end_sequence");
2192 Asm->EmitULEB128Bytes(1); Asm->EOL();
2193 Asm->EmitInt8(1); Asm->EOL();
2196 /// EmitDebugLines - Emit source line information.
2198 void DwarfDebug::EmitDebugLines() {
2199 // If the target is using .loc/.file, the assembler will be emitting the
2200 // .debug_line table automatically.
2201 if (TAI->hasDotLocAndDotFile())
2204 // Minimum line delta, thus ranging from -10..(255-10).
2205 const int MinLineDelta = -(dwarf::DW_LNS_fixed_advance_pc + 1);
2206 // Maximum line delta, thus ranging from -10..(255-10).
2207 const int MaxLineDelta = 255 + MinLineDelta;
2209 // Start the dwarf line section.
2210 Asm->SwitchToDataSection(TAI->getDwarfLineSection());
2212 // Construct the section header.
2213 EmitDifference("line_end", 0, "line_begin", 0, true);
2214 Asm->EOL("Length of Source Line Info");
2215 EmitLabel("line_begin", 0);
2217 Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->EOL("DWARF version number");
2219 EmitDifference("line_prolog_end", 0, "line_prolog_begin", 0, true);
2220 Asm->EOL("Prolog Length");
2221 EmitLabel("line_prolog_begin", 0);
2223 Asm->EmitInt8(1); Asm->EOL("Minimum Instruction Length");
2225 Asm->EmitInt8(1); Asm->EOL("Default is_stmt_start flag");
2227 Asm->EmitInt8(MinLineDelta); Asm->EOL("Line Base Value (Special Opcodes)");
2229 Asm->EmitInt8(MaxLineDelta); Asm->EOL("Line Range Value (Special Opcodes)");
2231 Asm->EmitInt8(-MinLineDelta); Asm->EOL("Special Opcode Base");
2233 // Line number standard opcode encodings argument count
2234 Asm->EmitInt8(0); Asm->EOL("DW_LNS_copy arg count");
2235 Asm->EmitInt8(1); Asm->EOL("DW_LNS_advance_pc arg count");
2236 Asm->EmitInt8(1); Asm->EOL("DW_LNS_advance_line arg count");
2237 Asm->EmitInt8(1); Asm->EOL("DW_LNS_set_file arg count");
2238 Asm->EmitInt8(1); Asm->EOL("DW_LNS_set_column arg count");
2239 Asm->EmitInt8(0); Asm->EOL("DW_LNS_negate_stmt arg count");
2240 Asm->EmitInt8(0); Asm->EOL("DW_LNS_set_basic_block arg count");
2241 Asm->EmitInt8(0); Asm->EOL("DW_LNS_const_add_pc arg count");
2242 Asm->EmitInt8(1); Asm->EOL("DW_LNS_fixed_advance_pc arg count");
2244 // Emit directories.
2245 for (unsigned DI = 1, DE = getNumSourceDirectories()+1; DI != DE; ++DI) {
2246 Asm->EmitString(getSourceDirectoryName(DI));
2247 Asm->EOL("Directory");
2250 Asm->EmitInt8(0); Asm->EOL("End of directories");
2253 for (unsigned SI = 1, SE = getNumSourceIds()+1; SI != SE; ++SI) {
2254 // Remember source id starts at 1.
2255 std::pair<unsigned, unsigned> Id = getSourceDirectoryAndFileIds(SI);
2256 Asm->EmitString(getSourceFileName(Id.second));
2258 Asm->EmitULEB128Bytes(Id.first);
2259 Asm->EOL("Directory #");
2260 Asm->EmitULEB128Bytes(0);
2261 Asm->EOL("Mod date");
2262 Asm->EmitULEB128Bytes(0);
2263 Asm->EOL("File size");
2266 Asm->EmitInt8(0); Asm->EOL("End of files");
2268 EmitLabel("line_prolog_end", 0);
2270 // A sequence for each text section.
2271 unsigned SecSrcLinesSize = SectionSourceLines.size();
2273 for (unsigned j = 0; j < SecSrcLinesSize; ++j) {
2274 // Isolate current sections line info.
2275 const std::vector<SrcLineInfo> &LineInfos = SectionSourceLines[j];
2277 if (Asm->isVerbose()) {
2278 const Section* S = SectionMap[j + 1];
2279 O << '\t' << TAI->getCommentString() << " Section"
2280 << S->getName() << '\n';
2285 // Dwarf assumes we start with first line of first source file.
2286 unsigned Source = 1;
2289 // Construct rows of the address, source, line, column matrix.
2290 for (unsigned i = 0, N = LineInfos.size(); i < N; ++i) {
2291 const SrcLineInfo &LineInfo = LineInfos[i];
2292 unsigned LabelID = MMI->MappedLabel(LineInfo.getLabelID());
2293 if (!LabelID) continue;
2295 if (!Asm->isVerbose())
2298 std::pair<unsigned, unsigned> SourceID =
2299 getSourceDirectoryAndFileIds(LineInfo.getSourceID());
2300 O << '\t' << TAI->getCommentString() << ' '
2301 << getSourceDirectoryName(SourceID.first) << ' '
2302 << getSourceFileName(SourceID.second)
2303 <<" :" << utostr_32(LineInfo.getLine()) << '\n';
2306 // Define the line address.
2307 Asm->EmitInt8(0); Asm->EOL("Extended Op");
2308 Asm->EmitInt8(TD->getPointerSize() + 1); Asm->EOL("Op size");
2309 Asm->EmitInt8(dwarf::DW_LNE_set_address); Asm->EOL("DW_LNE_set_address");
2310 EmitReference("label", LabelID); Asm->EOL("Location label");
2312 // If change of source, then switch to the new source.
2313 if (Source != LineInfo.getSourceID()) {
2314 Source = LineInfo.getSourceID();
2315 Asm->EmitInt8(dwarf::DW_LNS_set_file); Asm->EOL("DW_LNS_set_file");
2316 Asm->EmitULEB128Bytes(Source); Asm->EOL("New Source");
2319 // If change of line.
2320 if (Line != LineInfo.getLine()) {
2321 // Determine offset.
2322 int Offset = LineInfo.getLine() - Line;
2323 int Delta = Offset - MinLineDelta;
2326 Line = LineInfo.getLine();
2328 // If delta is small enough and in range...
2329 if (Delta >= 0 && Delta < (MaxLineDelta - 1)) {
2330 // ... then use fast opcode.
2331 Asm->EmitInt8(Delta - MinLineDelta); Asm->EOL("Line Delta");
2333 // ... otherwise use long hand.
2334 Asm->EmitInt8(dwarf::DW_LNS_advance_line);
2335 Asm->EOL("DW_LNS_advance_line");
2336 Asm->EmitSLEB128Bytes(Offset); Asm->EOL("Line Offset");
2337 Asm->EmitInt8(dwarf::DW_LNS_copy); Asm->EOL("DW_LNS_copy");
2340 // Copy the previous row (different address or source)
2341 Asm->EmitInt8(dwarf::DW_LNS_copy); Asm->EOL("DW_LNS_copy");
2345 EmitEndOfLineMatrix(j + 1);
2348 if (SecSrcLinesSize == 0)
2349 // Because we're emitting a debug_line section, we still need a line
2350 // table. The linker and friends expect it to exist. If there's nothing to
2351 // put into it, emit an empty table.
2352 EmitEndOfLineMatrix(1);
2354 EmitLabel("line_end", 0);
2358 /// EmitCommonDebugFrame - Emit common frame info into a debug frame section.
2360 void DwarfDebug::EmitCommonDebugFrame() {
2361 if (!TAI->doesDwarfRequireFrameSection())
2365 Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
2366 TargetFrameInfo::StackGrowsUp ?
2367 TD->getPointerSize() : -TD->getPointerSize();
2369 // Start the dwarf frame section.
2370 Asm->SwitchToDataSection(TAI->getDwarfFrameSection());
2372 EmitLabel("debug_frame_common", 0);
2373 EmitDifference("debug_frame_common_end", 0,
2374 "debug_frame_common_begin", 0, true);
2375 Asm->EOL("Length of Common Information Entry");
2377 EmitLabel("debug_frame_common_begin", 0);
2378 Asm->EmitInt32((int)dwarf::DW_CIE_ID);
2379 Asm->EOL("CIE Identifier Tag");
2380 Asm->EmitInt8(dwarf::DW_CIE_VERSION);
2381 Asm->EOL("CIE Version");
2382 Asm->EmitString("");
2383 Asm->EOL("CIE Augmentation");
2384 Asm->EmitULEB128Bytes(1);
2385 Asm->EOL("CIE Code Alignment Factor");
2386 Asm->EmitSLEB128Bytes(stackGrowth);
2387 Asm->EOL("CIE Data Alignment Factor");
2388 Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), false));
2389 Asm->EOL("CIE RA Column");
2391 std::vector<MachineMove> Moves;
2392 RI->getInitialFrameState(Moves);
2394 EmitFrameMoves(NULL, 0, Moves, false);
2396 Asm->EmitAlignment(2, 0, 0, false);
2397 EmitLabel("debug_frame_common_end", 0);
2402 /// EmitFunctionDebugFrame - Emit per function frame info into a debug frame
2405 DwarfDebug::EmitFunctionDebugFrame(const FunctionDebugFrameInfo&DebugFrameInfo){
2406 if (!TAI->doesDwarfRequireFrameSection())
2409 // Start the dwarf frame section.
2410 Asm->SwitchToDataSection(TAI->getDwarfFrameSection());
2412 EmitDifference("debug_frame_end", DebugFrameInfo.Number,
2413 "debug_frame_begin", DebugFrameInfo.Number, true);
2414 Asm->EOL("Length of Frame Information Entry");
2416 EmitLabel("debug_frame_begin", DebugFrameInfo.Number);
2418 EmitSectionOffset("debug_frame_common", "section_debug_frame",
2420 Asm->EOL("FDE CIE offset");
2422 EmitReference("func_begin", DebugFrameInfo.Number);
2423 Asm->EOL("FDE initial location");
2424 EmitDifference("func_end", DebugFrameInfo.Number,
2425 "func_begin", DebugFrameInfo.Number);
2426 Asm->EOL("FDE address range");
2428 EmitFrameMoves("func_begin", DebugFrameInfo.Number, DebugFrameInfo.Moves,
2431 Asm->EmitAlignment(2, 0, 0, false);
2432 EmitLabel("debug_frame_end", DebugFrameInfo.Number);
2437 void DwarfDebug::EmitDebugPubNamesPerCU(CompileUnit *Unit) {
2438 EmitDifference("pubnames_end", Unit->getID(),
2439 "pubnames_begin", Unit->getID(), true);
2440 Asm->EOL("Length of Public Names Info");
2442 EmitLabel("pubnames_begin", Unit->getID());
2444 Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->EOL("DWARF Version");
2446 EmitSectionOffset("info_begin", "section_info",
2447 Unit->getID(), 0, true, false);
2448 Asm->EOL("Offset of Compilation Unit Info");
2450 EmitDifference("info_end", Unit->getID(), "info_begin", Unit->getID(),
2452 Asm->EOL("Compilation Unit Length");
2454 StringMap<DIE*> &Globals = Unit->getGlobals();
2455 for (StringMap<DIE*>::const_iterator
2456 GI = Globals.begin(), GE = Globals.end(); GI != GE; ++GI) {
2457 const char *Name = GI->getKeyData();
2458 DIE * Entity = GI->second;
2460 Asm->EmitInt32(Entity->getOffset()); Asm->EOL("DIE offset");
2461 Asm->EmitString(Name, strlen(Name)); Asm->EOL("External Name");
2464 Asm->EmitInt32(0); Asm->EOL("End Mark");
2465 EmitLabel("pubnames_end", Unit->getID());
2470 /// EmitDebugPubNames - Emit visible names into a debug pubnames section.
2472 void DwarfDebug::EmitDebugPubNames() {
2473 // Start the dwarf pubnames section.
2474 Asm->SwitchToDataSection(TAI->getDwarfPubNamesSection());
2477 EmitDebugPubNamesPerCU(MainCU);
2481 for (unsigned i = 0, e = CompileUnits.size(); i != e; ++i)
2482 EmitDebugPubNamesPerCU(CompileUnits[i]);
2485 /// EmitDebugStr - Emit visible names into a debug str section.
2487 void DwarfDebug::EmitDebugStr() {
2488 // Check to see if it is worth the effort.
2489 if (!StringPool.empty()) {
2490 // Start the dwarf str section.
2491 Asm->SwitchToDataSection(TAI->getDwarfStrSection());
2493 // For each of strings in the string pool.
2494 for (unsigned StringID = 1, N = StringPool.size();
2495 StringID <= N; ++StringID) {
2496 // Emit a label for reference from debug information entries.
2497 EmitLabel("string", StringID);
2499 // Emit the string itself.
2500 const std::string &String = StringPool[StringID];
2501 Asm->EmitString(String); Asm->EOL();
2508 /// EmitDebugLoc - Emit visible names into a debug loc section.
2510 void DwarfDebug::EmitDebugLoc() {
2511 // Start the dwarf loc section.
2512 Asm->SwitchToDataSection(TAI->getDwarfLocSection());
2516 /// EmitDebugARanges - Emit visible names into a debug aranges section.
2518 void DwarfDebug::EmitDebugARanges() {
2519 // Start the dwarf aranges section.
2520 Asm->SwitchToDataSection(TAI->getDwarfARangesSection());
2524 CompileUnit *Unit = GetBaseCompileUnit();
2526 // Don't include size of length
2527 Asm->EmitInt32(0x1c); Asm->EOL("Length of Address Ranges Info");
2529 Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->EOL("Dwarf Version");
2531 EmitReference("info_begin", Unit->getID());
2532 Asm->EOL("Offset of Compilation Unit Info");
2534 Asm->EmitInt8(TD->getPointerSize()); Asm->EOL("Size of Address");
2536 Asm->EmitInt8(0); Asm->EOL("Size of Segment Descriptor");
2538 Asm->EmitInt16(0); Asm->EOL("Pad (1)");
2539 Asm->EmitInt16(0); Asm->EOL("Pad (2)");
2542 EmitReference("text_begin", 0); Asm->EOL("Address");
2543 EmitDifference("text_end", 0, "text_begin", 0, true); Asm->EOL("Length");
2545 Asm->EmitInt32(0); Asm->EOL("EOM (1)");
2546 Asm->EmitInt32(0); Asm->EOL("EOM (2)");
2552 /// EmitDebugRanges - Emit visible names into a debug ranges section.
2554 void DwarfDebug::EmitDebugRanges() {
2555 // Start the dwarf ranges section.
2556 Asm->SwitchToDataSection(TAI->getDwarfRangesSection());
2560 /// EmitDebugMacInfo - Emit visible names into a debug macinfo section.
2562 void DwarfDebug::EmitDebugMacInfo() {
2563 if (TAI->doesSupportMacInfoSection()) {
2564 // Start the dwarf macinfo section.
2565 Asm->SwitchToDataSection(TAI->getDwarfMacInfoSection());
2570 /// EmitDebugInlineInfo - Emit inline info using following format.
2572 /// 1. length of section
2573 /// 2. Dwarf version number
2574 /// 3. address size.
2576 /// Entries (one "entry" for each function that was inlined):
2578 /// 1. offset into __debug_str section for MIPS linkage name, if exists;
2579 /// otherwise offset into __debug_str for regular function name.
2580 /// 2. offset into __debug_str section for regular function name.
2581 /// 3. an unsigned LEB128 number indicating the number of distinct inlining
2582 /// instances for the function.
2584 /// The rest of the entry consists of a {die_offset, low_pc} pair for each
2585 /// inlined instance; the die_offset points to the inlined_subroutine die in the
2586 /// __debug_info section, and the low_pc is the starting address for the
2587 /// inlining instance.
2588 void DwarfDebug::EmitDebugInlineInfo() {
2589 if (!TAI->doesDwarfUsesInlineInfoSection())
2595 Asm->SwitchToDataSection(TAI->getDwarfDebugInlineSection());
2597 EmitDifference("debug_inlined_end", 1,
2598 "debug_inlined_begin", 1, true);
2599 Asm->EOL("Length of Debug Inlined Information Entry");
2601 EmitLabel("debug_inlined_begin", 1);
2603 Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->EOL("Dwarf Version");
2604 Asm->EmitInt8(TD->getPointerSize()); Asm->EOL("Address Size (in bytes)");
2606 for (DenseMap<GlobalVariable *, SmallVector<unsigned, 4> >::iterator
2607 I = InlineInfo.begin(), E = InlineInfo.end(); I != E; ++I) {
2608 GlobalVariable *GV = I->first;
2609 SmallVector<unsigned, 4> &Labels = I->second;
2610 DISubprogram SP(GV);
2614 SP.getLinkageName(LName);
2617 Asm->EmitString(LName.empty() ? Name : LName);
2618 Asm->EOL("MIPS linkage name");
2620 Asm->EmitString(Name); Asm->EOL("Function name");
2622 Asm->EmitULEB128Bytes(Labels.size()); Asm->EOL("Inline count");
2624 for (SmallVector<unsigned, 4>::iterator LI = Labels.begin(),
2625 LE = Labels.end(); LI != LE; ++LI) {
2626 DIE *SP = MainCU->getDieMapSlotFor(GV);
2627 Asm->EmitInt32(SP->getOffset()); Asm->EOL("DIE offset");
2629 if (TD->getPointerSize() == sizeof(int32_t))
2630 O << TAI->getData32bitsDirective();
2632 O << TAI->getData64bitsDirective();
2634 PrintLabelName("label", *LI); Asm->EOL("low_pc");
2638 EmitLabel("debug_inlined_end", 1);