LLVM API Documentation

DwarfUnit.h
Go to the documentation of this file.
00001 //===-- llvm/CodeGen/DwarfUnit.h - Dwarf Compile Unit ---*- C++ -*--===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains support for writing dwarf compile unit.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFUNIT_H
00015 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFUNIT_H
00016 
00017 #include "DIE.h"
00018 #include "DwarfDebug.h"
00019 #include "llvm/ADT/DenseMap.h"
00020 #include "llvm/ADT/Optional.h"
00021 #include "llvm/ADT/StringMap.h"
00022 #include "llvm/CodeGen/AsmPrinter.h"
00023 #include "llvm/IR/DIBuilder.h"
00024 #include "llvm/IR/DebugInfo.h"
00025 #include "llvm/MC/MCExpr.h"
00026 #include "llvm/MC/MCSection.h"
00027 #include "llvm/MC/MCDwarf.h"
00028 
00029 namespace llvm {
00030 
00031 class MachineLocation;
00032 class MachineOperand;
00033 class ConstantInt;
00034 class ConstantFP;
00035 class DbgVariable;
00036 class DwarfCompileUnit;
00037 
00038 // Data structure to hold a range for range lists.
00039 class RangeSpan {
00040 public:
00041   RangeSpan(MCSymbol *S, MCSymbol *E) : Start(S), End(E) {}
00042   const MCSymbol *getStart() const { return Start; }
00043   const MCSymbol *getEnd() const { return End; }
00044   void setEnd(const MCSymbol *E) { End = E; }
00045 
00046 private:
00047   const MCSymbol *Start, *End;
00048 };
00049 
00050 class RangeSpanList {
00051 private:
00052   // Index for locating within the debug_range section this particular span.
00053   MCSymbol *RangeSym;
00054   // List of ranges.
00055   SmallVector<RangeSpan, 2> Ranges;
00056 
00057 public:
00058   RangeSpanList(MCSymbol *Sym) : RangeSym(Sym) {}
00059   MCSymbol *getSym() const { return RangeSym; }
00060   const SmallVectorImpl<RangeSpan> &getRanges() const { return Ranges; }
00061   void addRange(RangeSpan Range) { Ranges.push_back(Range); }
00062 };
00063 
00064 //===----------------------------------------------------------------------===//
00065 /// Unit - This dwarf writer support class manages information associated
00066 /// with a source file.
00067 class DwarfUnit {
00068 protected:
00069   /// UniqueID - a numeric ID unique among all CUs in the module
00070   unsigned UniqueID;
00071 
00072   /// Node - MDNode for the compile unit.
00073   DICompileUnit CUNode;
00074 
00075   /// Unit debug information entry.
00076   DIE UnitDie;
00077 
00078   /// Offset of the UnitDie from beginning of debug info section.
00079   unsigned DebugInfoOffset;
00080 
00081   /// Asm - Target of Dwarf emission.
00082   AsmPrinter *Asm;
00083 
00084   // Holders for some common dwarf information.
00085   DwarfDebug *DD;
00086   DwarfFile *DU;
00087 
00088   /// IndexTyDie - An anonymous type for index type.  Owned by UnitDie.
00089   DIE *IndexTyDie;
00090 
00091   /// MDNodeToDieMap - Tracks the mapping of unit level debug information
00092   /// variables to debug information entries.
00093   DenseMap<const MDNode *, DIE *> MDNodeToDieMap;
00094 
00095   /// MDNodeToDIEEntryMap - Tracks the mapping of unit level debug information
00096   /// descriptors to debug information entries using a DIEEntry proxy.
00097   DenseMap<const MDNode *, DIEEntry *> MDNodeToDIEEntryMap;
00098 
00099   /// GlobalNames - A map of globally visible named entities for this unit.
00100   StringMap<const DIE *> GlobalNames;
00101 
00102   /// GlobalTypes - A map of globally visible types for this unit.
00103   StringMap<const DIE *> GlobalTypes;
00104 
00105   /// DIEBlocks - A list of all the DIEBlocks in use.
00106   std::vector<DIEBlock *> DIEBlocks;
00107   
00108   /// DIELocs - A list of all the DIELocs in use.
00109   std::vector<DIELoc *> DIELocs;
00110 
00111   /// ContainingTypeMap - This map is used to keep track of subprogram DIEs that
00112   /// need DW_AT_containing_type attribute. This attribute points to a DIE that
00113   /// corresponds to the MDNode mapped with the subprogram DIE.
00114   DenseMap<DIE *, const MDNode *> ContainingTypeMap;
00115 
00116   // List of ranges for a given compile unit.
00117   SmallVector<RangeSpan, 1> CURanges;
00118 
00119   // List of range lists for a given compile unit, separate from the ranges for
00120   // the CU itself.
00121   SmallVector<RangeSpanList, 1> CURangeLists;
00122 
00123   // DIEValueAllocator - All DIEValues are allocated through this allocator.
00124   BumpPtrAllocator DIEValueAllocator;
00125 
00126   // DIEIntegerOne - A preallocated DIEValue because 1 is used frequently.
00127   DIEInteger *DIEIntegerOne;
00128 
00129   /// The section this unit will be emitted in.
00130   const MCSection *Section;
00131 
00132   /// A label at the start of the non-dwo section related to this unit.
00133   MCSymbol *SectionSym;
00134 
00135   /// The start of the unit within its section.
00136   MCSymbol *LabelBegin;
00137 
00138   /// The end of the unit within its section.
00139   MCSymbol *LabelEnd;
00140 
00141   /// Skeleton unit associated with this unit.
00142   DwarfUnit *Skeleton;
00143 
00144   DwarfUnit(unsigned UID, dwarf::Tag, DICompileUnit CU, AsmPrinter *A,
00145             DwarfDebug *DW, DwarfFile *DWU);
00146 
00147 public:
00148   virtual ~DwarfUnit();
00149 
00150   /// Set the skeleton unit associated with this unit.
00151   void setSkeleton(DwarfUnit &Skel) { Skeleton = &Skel; }
00152 
00153   /// Get the skeleton unit associated with this unit.
00154   DwarfUnit *getSkeleton() const { return Skeleton; }
00155 
00156   /// Pass in the SectionSym even though we could recreate it in every compile
00157   /// unit (type units will have actually distinct symbols once they're in
00158   /// comdat sections).
00159   void initSection(const MCSection *Section, MCSymbol *SectionSym) {
00160     assert(!this->Section);
00161     this->Section = Section;
00162     this->SectionSym = SectionSym;
00163     this->LabelBegin =
00164         Asm->GetTempSymbol(Section->getLabelBeginName(), getUniqueID());
00165     this->LabelEnd =
00166         Asm->GetTempSymbol(Section->getLabelEndName(), getUniqueID());
00167   }
00168 
00169   const MCSection *getSection() const {
00170     assert(Section);
00171     return Section;
00172   }
00173 
00174   /// If there's a skeleton then return the section symbol for the skeleton
00175   /// unit, otherwise return the section symbol for this unit.
00176   MCSymbol *getLocalSectionSym() const {
00177     if (Skeleton)
00178       return Skeleton->getSectionSym();
00179     return getSectionSym();
00180   }
00181 
00182   MCSymbol *getSectionSym() const {
00183     assert(Section);
00184     return SectionSym;
00185   }
00186 
00187   /// If there's a skeleton then return the begin label for the skeleton unit,
00188   /// otherwise return the local label for this unit.
00189   MCSymbol *getLocalLabelBegin() const {
00190     if (Skeleton)
00191       return Skeleton->getLabelBegin();
00192     return getLabelBegin();
00193   }
00194 
00195   MCSymbol *getLabelBegin() const {
00196     assert(Section);
00197     return LabelBegin;
00198   }
00199 
00200   MCSymbol *getLabelEnd() const {
00201     assert(Section);
00202     return LabelEnd;
00203   }
00204 
00205   // Accessors.
00206   unsigned getUniqueID() const { return UniqueID; }
00207   uint16_t getLanguage() const { return CUNode.getLanguage(); }
00208   DICompileUnit getCUNode() const { return CUNode; }
00209   DIE &getUnitDie() { return UnitDie; }
00210   const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; }
00211   const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; }
00212 
00213   unsigned getDebugInfoOffset() const { return DebugInfoOffset; }
00214   void setDebugInfoOffset(unsigned DbgInfoOff) { DebugInfoOffset = DbgInfoOff; }
00215 
00216   /// hasContent - Return true if this compile unit has something to write out.
00217   bool hasContent() const { return !UnitDie.getChildren().empty(); }
00218 
00219   /// getRanges - Get the list of ranges for this unit.
00220   const SmallVectorImpl<RangeSpan> &getRanges() const { return CURanges; }
00221   SmallVectorImpl<RangeSpan> &getRanges() { return CURanges; }
00222 
00223   /// addRangeList - Add an address range list to the list of range lists.
00224   void addRangeList(RangeSpanList Ranges) { CURangeLists.push_back(Ranges); }
00225 
00226   /// getRangeLists - Get the vector of range lists.
00227   const SmallVectorImpl<RangeSpanList> &getRangeLists() const {
00228     return CURangeLists;
00229   }
00230   SmallVectorImpl<RangeSpanList> &getRangeLists() { return CURangeLists; }
00231 
00232   /// getParentContextString - Get a string containing the language specific
00233   /// context for a global name.
00234   std::string getParentContextString(DIScope Context) const;
00235 
00236   /// addGlobalName - Add a new global entity to the compile unit.
00237   ///
00238   void addGlobalName(StringRef Name, DIE &Die, DIScope Context);
00239 
00240   /// addAccelNamespace - Add a new name to the namespace accelerator table.
00241   void addAccelNamespace(StringRef Name, const DIE &Die);
00242 
00243   /// getDIE - Returns the debug information entry map slot for the
00244   /// specified debug variable. We delegate the request to DwarfDebug
00245   /// when the MDNode can be part of the type system, since DIEs for
00246   /// the type system can be shared across CUs and the mappings are
00247   /// kept in DwarfDebug.
00248   DIE *getDIE(DIDescriptor D) const;
00249 
00250   /// getDIELoc - Returns a fresh newly allocated DIELoc.
00251   DIELoc *getDIELoc() { return new (DIEValueAllocator) DIELoc(); }
00252 
00253   /// insertDIE - Insert DIE into the map. We delegate the request to DwarfDebug
00254   /// when the MDNode can be part of the type system, since DIEs for
00255   /// the type system can be shared across CUs and the mappings are
00256   /// kept in DwarfDebug.
00257   void insertDIE(DIDescriptor Desc, DIE *D);
00258 
00259   /// addFlag - Add a flag that is true to the DIE.
00260   void addFlag(DIE &Die, dwarf::Attribute Attribute);
00261 
00262   /// addUInt - Add an unsigned integer attribute data and value.
00263   void addUInt(DIE &Die, dwarf::Attribute Attribute, Optional<dwarf::Form> Form,
00264                uint64_t Integer);
00265 
00266   void addUInt(DIE &Block, dwarf::Form Form, uint64_t Integer);
00267 
00268   /// addSInt - Add an signed integer attribute data and value.
00269   void addSInt(DIE &Die, dwarf::Attribute Attribute, Optional<dwarf::Form> Form,
00270                int64_t Integer);
00271 
00272   void addSInt(DIELoc &Die, Optional<dwarf::Form> Form, int64_t Integer);
00273 
00274   /// addString - Add a string attribute data and value.
00275   void addString(DIE &Die, dwarf::Attribute Attribute, StringRef Str);
00276 
00277   /// addLocalString - Add a string attribute data and value.
00278   void addLocalString(DIE &Die, dwarf::Attribute Attribute,
00279                       StringRef Str);
00280 
00281   /// addExpr - Add a Dwarf expression attribute data and value.
00282   void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr);
00283 
00284   /// addLabel - Add a Dwarf label attribute data and value.
00285   void addLabel(DIE &Die, dwarf::Attribute Attribute, dwarf::Form Form,
00286                 const MCSymbol *Label);
00287 
00288   void addLabel(DIELoc &Die, dwarf::Form Form, const MCSymbol *Label);
00289 
00290   /// addLocationList - Add a Dwarf loclistptr attribute data and value.
00291   void addLocationList(DIE &Die, dwarf::Attribute Attribute, unsigned Index);
00292 
00293   /// addSectionLabel - Add a Dwarf section label attribute data and value.
00294   ///
00295   void addSectionLabel(DIE &Die, dwarf::Attribute Attribute,
00296                        const MCSymbol *Label);
00297 
00298   /// addSectionOffset - Add an offset into a section attribute data and value.
00299   ///
00300   void addSectionOffset(DIE &Die, dwarf::Attribute Attribute, uint64_t Integer);
00301 
00302   /// addOpAddress - Add a dwarf op address data and value using the
00303   /// form given and an op of either DW_FORM_addr or DW_FORM_GNU_addr_index.
00304   void addOpAddress(DIELoc &Die, const MCSymbol *Label);
00305 
00306   /// addSectionDelta - Add a label delta attribute data and value.
00307   void addSectionDelta(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Hi,
00308                        const MCSymbol *Lo);
00309 
00310   /// addLabelDelta - Add a label delta attribute data and value.
00311   void addLabelDelta(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Hi,
00312                      const MCSymbol *Lo);
00313 
00314   /// addDIEEntry - Add a DIE attribute data and value.
00315   void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry);
00316 
00317   /// addDIEEntry - Add a DIE attribute data and value.
00318   void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIEEntry *Entry);
00319 
00320   void addDIETypeSignature(DIE &Die, const DwarfTypeUnit &Type);
00321 
00322   /// addBlock - Add block data.
00323   void addBlock(DIE &Die, dwarf::Attribute Attribute, DIELoc *Block);
00324 
00325   /// addBlock - Add block data.
00326   void addBlock(DIE &Die, dwarf::Attribute Attribute, DIEBlock *Block);
00327 
00328   /// addSourceLine - Add location information to specified debug information
00329   /// entry.
00330   void addSourceLine(DIE &Die, unsigned Line, StringRef File,
00331                      StringRef Directory);
00332   void addSourceLine(DIE &Die, DIVariable V);
00333   void addSourceLine(DIE &Die, DIGlobalVariable G);
00334   void addSourceLine(DIE &Die, DISubprogram SP);
00335   void addSourceLine(DIE &Die, DIType Ty);
00336   void addSourceLine(DIE &Die, DINameSpace NS);
00337   void addSourceLine(DIE &Die, DIObjCProperty Ty);
00338 
00339   /// addAddress - Add an address attribute to a die based on the location
00340   /// provided.
00341   void addAddress(DIE &Die, dwarf::Attribute Attribute,
00342                   const MachineLocation &Location, bool Indirect = false);
00343 
00344   /// addConstantValue - Add constant value entry in variable DIE.
00345   void addConstantValue(DIE &Die, const MachineOperand &MO, DIType Ty);
00346   void addConstantValue(DIE &Die, const ConstantInt *CI, DIType Ty);
00347   void addConstantValue(DIE &Die, const APInt &Val, DIType Ty);
00348   void addConstantValue(DIE &Die, const APInt &Val, bool Unsigned);
00349   void addConstantValue(DIE &Die, bool Unsigned, uint64_t Val);
00350 
00351   /// addConstantFPValue - Add constant value entry in variable DIE.
00352   void addConstantFPValue(DIE &Die, const MachineOperand &MO);
00353   void addConstantFPValue(DIE &Die, const ConstantFP *CFP);
00354 
00355   /// addTemplateParams - Add template parameters in buffer.
00356   void addTemplateParams(DIE &Buffer, DIArray TParams);
00357 
00358   /// addRegisterOp - Add register operand.
00359   void addRegisterOpPiece(DIELoc &TheDie, unsigned Reg,
00360                           unsigned SizeInBits = 0, unsigned OffsetInBits = 0);
00361 
00362   /// addRegisterOffset - Add register offset.
00363   void addRegisterOffset(DIELoc &TheDie, unsigned Reg, int64_t Offset);
00364 
00365   /// addComplexAddress - Start with the address based on the location provided,
00366   /// and generate the DWARF information necessary to find the actual variable
00367   /// (navigating the extra location information encoded in the type) based on
00368   /// the starting location.  Add the DWARF information to the die.
00369   void addComplexAddress(const DbgVariable &DV, DIE &Die,
00370                          dwarf::Attribute Attribute,
00371                          const MachineLocation &Location);
00372 
00373   // FIXME: Should be reformulated in terms of addComplexAddress.
00374   /// addBlockByrefAddress - Start with the address based on the location
00375   /// provided, and generate the DWARF information necessary to find the
00376   /// actual Block variable (navigating the Block struct) based on the
00377   /// starting location.  Add the DWARF information to the die.  Obsolete,
00378   /// please use addComplexAddress instead.
00379   void addBlockByrefAddress(const DbgVariable &DV, DIE &Die,
00380                             dwarf::Attribute Attribute,
00381                             const MachineLocation &Location);
00382 
00383   /// addVariableAddress - Add DW_AT_location attribute for a
00384   /// DbgVariable based on provided MachineLocation.
00385   void addVariableAddress(const DbgVariable &DV, DIE &Die,
00386                           MachineLocation Location);
00387 
00388   /// addType - Add a new type attribute to the specified entity. This takes
00389   /// and attribute parameter because DW_AT_friend attributes are also
00390   /// type references.
00391   void addType(DIE &Entity, DIType Ty,
00392                dwarf::Attribute Attribute = dwarf::DW_AT_type);
00393 
00394   /// getOrCreateNameSpace - Create a DIE for DINameSpace.
00395   DIE *getOrCreateNameSpace(DINameSpace NS);
00396 
00397   /// getOrCreateSubprogramDIE - Create new DIE using SP.
00398   DIE *getOrCreateSubprogramDIE(DISubprogram SP);
00399 
00400   void applySubprogramAttributes(DISubprogram SP, DIE &SPDie);
00401   void applySubprogramAttributesToDefinition(DISubprogram SP, DIE &SPDie);
00402   void applyVariableAttributes(const DbgVariable &Var, DIE &VariableDie);
00403 
00404   /// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
00405   /// given DIType.
00406   DIE *getOrCreateTypeDIE(const MDNode *N);
00407 
00408   /// getOrCreateContextDIE - Get context owner's DIE.
00409   DIE *createTypeDIE(DICompositeType Ty);
00410 
00411   /// getOrCreateContextDIE - Get context owner's DIE.
00412   DIE *getOrCreateContextDIE(DIScope Context);
00413 
00414   /// constructContainingTypeDIEs - Construct DIEs for types that contain
00415   /// vtables.
00416   void constructContainingTypeDIEs();
00417 
00418   /// constructVariableDIE - Construct a DIE for the given DbgVariable.
00419   std::unique_ptr<DIE> constructVariableDIE(DbgVariable &DV,
00420                                             bool Abstract = false);
00421 
00422   /// constructSubprogramArguments - Construct function argument DIEs.
00423   void constructSubprogramArguments(DIE &Buffer, DITypeArray Args);
00424 
00425   /// Create a DIE with the given Tag, add the DIE to its parent, and
00426   /// call insertDIE if MD is not null.
00427   DIE &createAndAddDIE(unsigned Tag, DIE &Parent,
00428                        DIDescriptor N = DIDescriptor());
00429 
00430   /// Compute the size of a header for this unit, not including the initial
00431   /// length field.
00432   virtual unsigned getHeaderSize() const {
00433     return sizeof(int16_t) + // DWARF version number
00434            sizeof(int32_t) + // Offset Into Abbrev. Section
00435            sizeof(int8_t);   // Pointer Size (in bytes)
00436   }
00437 
00438   /// Emit the header for this unit, not including the initial length field.
00439   virtual void emitHeader(const MCSymbol *ASectionSym) const;
00440 
00441   virtual DwarfCompileUnit &getCU() = 0;
00442 
00443   /// constructTypeDIE - Construct type DIE from DICompositeType.
00444   void constructTypeDIE(DIE &Buffer, DICompositeType CTy);
00445 
00446 protected:
00447   /// getOrCreateStaticMemberDIE - Create new static data member DIE.
00448   DIE *getOrCreateStaticMemberDIE(DIDerivedType DT);
00449 
00450   /// Look up the source ID with the given directory and source file names. If
00451   /// none currently exists, create a new ID and insert it in the line table.
00452   virtual unsigned getOrCreateSourceID(StringRef File, StringRef Directory) = 0;
00453 
00454 private:
00455   /// \brief Construct a DIE for the given DbgVariable without initializing the
00456   /// DbgVariable's DIE reference.
00457   std::unique_ptr<DIE> constructVariableDIEImpl(const DbgVariable &DV,
00458                                                 bool Abstract);
00459 
00460   /// constructTypeDIE - Construct basic type die from DIBasicType.
00461   void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
00462 
00463   /// constructTypeDIE - Construct derived type die from DIDerivedType.
00464   void constructTypeDIE(DIE &Buffer, DIDerivedType DTy);
00465 
00466   /// constructSubrangeDIE - Construct subrange DIE from DISubrange.
00467   void constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy);
00468 
00469   /// constructArrayTypeDIE - Construct array type DIE from DICompositeType.
00470   void constructArrayTypeDIE(DIE &Buffer, DICompositeType CTy);
00471 
00472   /// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator.
00473   void constructEnumTypeDIE(DIE &Buffer, DICompositeType CTy);
00474 
00475   /// constructMemberDIE - Construct member DIE from DIDerivedType.
00476   void constructMemberDIE(DIE &Buffer, DIDerivedType DT);
00477 
00478   /// constructTemplateTypeParameterDIE - Construct new DIE for the given
00479   /// DITemplateTypeParameter.
00480   void constructTemplateTypeParameterDIE(DIE &Buffer,
00481                                          DITemplateTypeParameter TP);
00482 
00483   /// constructTemplateValueParameterDIE - Construct new DIE for the given
00484   /// DITemplateValueParameter.
00485   void constructTemplateValueParameterDIE(DIE &Buffer,
00486                                           DITemplateValueParameter TVP);
00487 
00488   /// getLowerBoundDefault - Return the default lower bound for an array. If the
00489   /// DWARF version doesn't handle the language, return -1.
00490   int64_t getDefaultLowerBound() const;
00491 
00492   /// getDIEEntry - Returns the debug information entry for the specified
00493   /// debug variable.
00494   DIEEntry *getDIEEntry(const MDNode *N) const {
00495     return MDNodeToDIEEntryMap.lookup(N);
00496   }
00497 
00498   /// insertDIEEntry - Insert debug information entry into the map.
00499   void insertDIEEntry(const MDNode *N, DIEEntry *E) {
00500     MDNodeToDIEEntryMap.insert(std::make_pair(N, E));
00501   }
00502 
00503   // getIndexTyDie - Get an anonymous type for index type.
00504   DIE *getIndexTyDie() { return IndexTyDie; }
00505 
00506   // setIndexTyDie - Set D as anonymous type for index which can be reused
00507   // later.
00508   void setIndexTyDie(DIE *D) { IndexTyDie = D; }
00509 
00510   /// createDIEEntry - Creates a new DIEEntry to be a proxy for a debug
00511   /// information entry.
00512   DIEEntry *createDIEEntry(DIE &Entry);
00513 
00514   /// resolve - Look in the DwarfDebug map for the MDNode that
00515   /// corresponds to the reference.
00516   template <typename T> T resolve(DIRef<T> Ref) const {
00517     return DD->resolve(Ref);
00518   }
00519 
00520   /// If this is a named finished type then include it in the list of types for
00521   /// the accelerator tables.
00522   void updateAcceleratorTables(DIScope Context, DIType Ty, const DIE &TyDIE);
00523 };
00524 
00525 class DwarfCompileUnit : public DwarfUnit {
00526   /// The attribute index of DW_AT_stmt_list in the compile unit DIE, avoiding
00527   /// the need to search for it in applyStmtList.
00528   unsigned stmtListIndex;
00529 
00530 public:
00531   DwarfCompileUnit(unsigned UID, DICompileUnit Node, AsmPrinter *A,
00532                    DwarfDebug *DW, DwarfFile *DWU);
00533 
00534   void initStmtList(MCSymbol *DwarfLineSectionSym);
00535 
00536   /// Apply the DW_AT_stmt_list from this compile unit to the specified DIE.
00537   void applyStmtList(DIE &D);
00538 
00539   /// createGlobalVariableDIE - create global variable DIE.
00540   void createGlobalVariableDIE(DIGlobalVariable GV);
00541 
00542   /// addLabelAddress - Add a dwarf label attribute data and value using
00543   /// either DW_FORM_addr or DW_FORM_GNU_addr_index.
00544   void addLabelAddress(DIE &Die, dwarf::Attribute Attribute,
00545                        const MCSymbol *Label);
00546 
00547   /// addLocalLabelAddress - Add a dwarf label attribute data and value using
00548   /// DW_FORM_addr only.
00549   void addLocalLabelAddress(DIE &Die, dwarf::Attribute Attribute,
00550                             const MCSymbol *Label);
00551 
00552   DwarfCompileUnit &getCU() override { return *this; }
00553 
00554   unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName) override;
00555 
00556   /// addRange - Add an address range to the list of ranges for this unit.
00557   void addRange(RangeSpan Range);
00558 };
00559 
00560 class DwarfTypeUnit : public DwarfUnit {
00561 private:
00562   uint64_t TypeSignature;
00563   const DIE *Ty;
00564   DwarfCompileUnit &CU;
00565   MCDwarfDwoLineTable *SplitLineTable;
00566 
00567 public:
00568   DwarfTypeUnit(unsigned UID, DwarfCompileUnit &CU, AsmPrinter *A,
00569                 DwarfDebug *DW, DwarfFile *DWU,
00570                 MCDwarfDwoLineTable *SplitLineTable = nullptr);
00571 
00572   void setTypeSignature(uint64_t Signature) { TypeSignature = Signature; }
00573   uint64_t getTypeSignature() const { return TypeSignature; }
00574   void setType(const DIE *Ty) { this->Ty = Ty; }
00575 
00576   /// Emit the header for this unit, not including the initial length field.
00577   void emitHeader(const MCSymbol *ASectionSym) const override;
00578   unsigned getHeaderSize() const override {
00579     return DwarfUnit::getHeaderSize() + sizeof(uint64_t) + // Type Signature
00580            sizeof(uint32_t);                               // Type DIE Offset
00581   }
00582   void initSection(const MCSection *Section);
00583   // Bring in the base function (taking two args, including the section symbol)
00584   // for use when building DWO type units (they don't go in unique comdat
00585   // sections)
00586   using DwarfUnit::initSection;
00587   DwarfCompileUnit &getCU() override { return CU; }
00588 
00589 protected:
00590   unsigned getOrCreateSourceID(StringRef File, StringRef Directory) override;
00591 };
00592 } // end llvm namespace
00593 #endif