LCOV - code coverage report
Current view: top level - lib/CodeGen/AsmPrinter - DwarfFile.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 9 11 81.8 %
Date: 2018-10-20 13:21:21 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- llvm/CodeGen/DwarfFile.h - Dwarf Debug Framework ---------*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : 
      10             : #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H
      11             : #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H
      12             : 
      13             : #include "DwarfStringPool.h"
      14             : #include "llvm/ADT/DenseMap.h"
      15             : #include "llvm/ADT/SmallVector.h"
      16             : #include "llvm/ADT/StringRef.h"
      17             : #include "llvm/CodeGen/DIE.h"
      18             : #include "llvm/IR/Metadata.h"
      19             : #include "llvm/Support/Allocator.h"
      20             : #include <map>
      21             : #include <memory>
      22             : #include <utility>
      23             : 
      24             : namespace llvm {
      25             : 
      26             : class AsmPrinter;
      27             : class DbgEntity;
      28             : class DbgVariable;
      29             : class DbgLabel;
      30             : class DwarfCompileUnit;
      31             : class DwarfUnit;
      32             : class LexicalScope;
      33             : class MCSection;
      34             : 
      35             : class DwarfFile {
      36             :   // Target of Dwarf emission, used for sizing of abbreviations.
      37             :   AsmPrinter *Asm;
      38             : 
      39             :   BumpPtrAllocator AbbrevAllocator;
      40             : 
      41             :   // Used to uniquely define abbreviations.
      42             :   DIEAbbrevSet Abbrevs;
      43             : 
      44             :   // A pointer to all units in the section.
      45             :   SmallVector<std::unique_ptr<DwarfCompileUnit>, 1> CUs;
      46             : 
      47             :   DwarfStringPool StrPool;
      48             : 
      49             :   /// DWARF v5: The symbol that designates the start of the contribution to
      50             :   /// the string offsets table. The contribution is shared by all units.
      51             :   MCSymbol *StringOffsetsStartSym = nullptr;
      52             : 
      53             :   /// DWARF v5: The symbol that designates the base of the range list table.
      54             :   /// The table is shared by all units.
      55             :   MCSymbol *RnglistsTableBaseSym = nullptr;
      56             : 
      57             :   /// The variables of a lexical scope.
      58             :   struct ScopeVars {
      59             :     /// We need to sort Args by ArgNo and check for duplicates. This could also
      60             :     /// be implemented as a list or vector + std::lower_bound().
      61             :     std::map<unsigned, DbgVariable *> Args;
      62             :     SmallVector<DbgVariable *, 8> Locals;
      63             :   };
      64             :   /// Collection of DbgVariables of each lexical scope.
      65             :   DenseMap<LexicalScope *, ScopeVars> ScopeVariables;
      66             : 
      67             :   /// Collection of DbgLabels of each lexical scope.
      68             :   using LabelList = SmallVector<DbgLabel *, 4>;
      69             :   DenseMap<LexicalScope *, LabelList> ScopeLabels;
      70             : 
      71             :   // Collection of abstract subprogram DIEs.
      72             :   DenseMap<const MDNode *, DIE *> AbstractSPDies;
      73             :   DenseMap<const DINode *, std::unique_ptr<DbgEntity>> AbstractEntities;
      74             : 
      75             :   /// Maps MDNodes for type system with the corresponding DIEs. These DIEs can
      76             :   /// be shared across CUs, that is why we keep the map here instead
      77             :   /// of in DwarfCompileUnit.
      78             :   DenseMap<const MDNode *, DIE *> DITypeNodeToDieMap;
      79             : 
      80             : public:
      81             :   DwarfFile(AsmPrinter *AP, StringRef Pref, BumpPtrAllocator &DA);
      82             : 
      83             :   const SmallVectorImpl<std::unique_ptr<DwarfCompileUnit>> &getUnits() {
      84             :     return CUs;
      85             :   }
      86             : 
      87             :   /// Compute the size and offset of a DIE given an incoming Offset.
      88             :   unsigned computeSizeAndOffset(DIE &Die, unsigned Offset);
      89             : 
      90             :   /// Compute the size and offset of all the DIEs.
      91             :   void computeSizeAndOffsets();
      92             : 
      93             :   /// Compute the size and offset of all the DIEs in the given unit.
      94             :   /// \returns The size of the root DIE.
      95             :   unsigned computeSizeAndOffsetsForUnit(DwarfUnit *TheU);
      96             : 
      97             :   /// Add a unit to the list of CUs.
      98             :   void addUnit(std::unique_ptr<DwarfCompileUnit> U);
      99             : 
     100             :   /// Emit all of the units to the section listed with the given
     101             :   /// abbreviation section.
     102             :   void emitUnits(bool UseOffsets);
     103             : 
     104             :   /// Emit the given unit to its section.
     105             :   void emitUnit(DwarfUnit *U, bool UseOffsets);
     106             : 
     107             :   /// Emit a set of abbreviations to the specific section.
     108             :   void emitAbbrevs(MCSection *);
     109             : 
     110             :   /// Emit all of the strings to the section given. If OffsetSection is
     111             :   /// non-null, emit a table of string offsets to it. If UseRelativeOffsets
     112             :   /// is false, emit absolute offsets to the strings. Otherwise, emit
     113             :   /// relocatable references to the strings if they are supported by the target.
     114             :   void emitStrings(MCSection *StrSection, MCSection *OffsetSection = nullptr,
     115             :                    bool UseRelativeOffsets = false);
     116             : 
     117             :   /// Returns the string pool.
     118      153069 :   DwarfStringPool &getStringPool() { return StrPool; }
     119             : 
     120           0 :   MCSymbol *getStringOffsetsStartSym() const { return StringOffsetsStartSym; }
     121             : 
     122          37 :   void setStringOffsetsStartSym(MCSymbol *Sym) { StringOffsetsStartSym = Sym; }
     123             : 
     124           0 :   MCSymbol *getRnglistsTableBaseSym() const { return RnglistsTableBaseSym; }
     125             : 
     126          37 :   void setRnglistsTableBaseSym(MCSymbol *Sym) { RnglistsTableBaseSym = Sym; }
     127             : 
     128             :   /// \returns false if the variable was merged with a previous one.
     129             :   bool addScopeVariable(LexicalScope *LS, DbgVariable *Var);
     130             : 
     131             :   void addScopeLabel(LexicalScope *LS, DbgLabel *Label);
     132             : 
     133             :   DenseMap<LexicalScope *, ScopeVars> &getScopeVariables() {
     134      224585 :     return ScopeVariables;
     135             :   }
     136             : 
     137             :   DenseMap<LexicalScope *, LabelList> &getScopeLabels() {
     138      224585 :     return ScopeLabels;
     139             :   }
     140             : 
     141             :   DenseMap<const MDNode *, DIE *> &getAbstractSPDies() {
     142      229309 :     return AbstractSPDies;
     143             :   }
     144             : 
     145             :   DenseMap<const DINode *, std::unique_ptr<DbgEntity>> &getAbstractEntities() {
     146      185218 :     return AbstractEntities;
     147             :   }
     148             : 
     149             :   void insertDIE(const MDNode *TypeMD, DIE *Die) {
     150       77730 :     DITypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
     151             :   }
     152             : 
     153             :   DIE *getDIE(const MDNode *TypeMD) {
     154      581796 :     return DITypeNodeToDieMap.lookup(TypeMD);
     155             :   }
     156             : };
     157             : 
     158             : } // end namespace llvm
     159             : 
     160             : #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H

Generated by: LCOV version 1.13