[llvm] b6b0ff1 - [DebugInfo] Clean up DIEUnit. NFC.

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 7 02:09:34 PDT 2020


Author: Igor Kudrin
Date: 2020-08-07T15:55:44+07:00
New Revision: b6b0ff18a3126500361223088aabafa8ea74d779

URL: https://github.com/llvm/llvm-project/commit/b6b0ff18a3126500361223088aabafa8ea74d779
DIFF: https://github.com/llvm/llvm-project/commit/b6b0ff18a3126500361223088aabafa8ea74d779.diff

LOG: [DebugInfo] Clean up DIEUnit. NFC.

This removes members of the DIEUnit class which were used only in unit
tests. Note also that child classes shadowed some of these methods,
namely, getDwarfVersion() was overridden in DwartfUnit and getLength()
was overridden in DwarfCompileUnit.

Differential Revision: https://reviews.llvm.org/D85436

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/DIE.h
    llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
    llvm/lib/CodeGen/AsmPrinter/DIE.cpp
    llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
    llvm/unittests/DebugInfo/DWARF/DwarfGenerator.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/DIE.h b/llvm/include/llvm/CodeGen/DIE.h
index c7baaf6aef3d..43ba859fdc79 100644
--- a/llvm/include/llvm/CodeGen/DIE.h
+++ b/llvm/include/llvm/CodeGen/DIE.h
@@ -864,14 +864,11 @@ class DIEUnit {
   /// a valid section depending on the client that is emitting DWARF.
   MCSection *Section;
   uint64_t Offset; /// .debug_info or .debug_types absolute section offset.
-  uint32_t Length; /// The length in bytes of all of the DIEs in this unit.
-  const uint16_t Version; /// The Dwarf version number for this unit.
-  const uint8_t AddrSize; /// The size in bytes of an address for this unit.
 protected:
   virtual ~DIEUnit() = default;
 
 public:
-  DIEUnit(uint16_t Version, uint8_t AddrSize, dwarf::Tag UnitTag);
+  explicit DIEUnit(dwarf::Tag UnitTag);
   DIEUnit(const DIEUnit &RHS) = delete;
   DIEUnit(DIEUnit &&RHS) = delete;
   void operator=(const DIEUnit &RHS) = delete;
@@ -895,17 +892,12 @@ class DIEUnit {
   MCSection *getSection() const { return Section; }
   void setDebugSectionOffset(unsigned O) { Offset = O; }
   unsigned getDebugSectionOffset() const { return Offset; }
-  void setLength(uint64_t L) { Length = L; }
-  uint64_t getLength() const { return Length; }
-  uint16_t getDwarfVersion() const { return Version; }
-  uint16_t getAddressSize() const { return AddrSize; }
   DIE &getUnitDie() { return Die; }
   const DIE &getUnitDie() const { return Die; }
 };
 
 struct BasicDIEUnit final : DIEUnit {
-  BasicDIEUnit(uint16_t Version, uint8_t AddrSize, dwarf::Tag UnitTag)
-      : DIEUnit(Version, AddrSize, UnitTag) {}
+  explicit BasicDIEUnit(dwarf::Tag UnitTag) : DIEUnit(UnitTag) {}
 };
 
 //===--------------------------------------------------------------------===//

diff  --git a/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h b/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
index 944e7e3501c9..6c1649a68f3f 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
+++ b/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
@@ -101,10 +101,7 @@ class CompileUnit {
 
   unsigned getUniqueID() const { return ID; }
 
-  void createOutputDIE() {
-    NewUnit.emplace(OrigUnit.getVersion(), OrigUnit.getAddressByteSize(),
-                    OrigUnit.getUnitDIE().getTag());
-  }
+  void createOutputDIE() { NewUnit.emplace(OrigUnit.getUnitDIE().getTag()); }
 
   DIE *getOutputUnitDIE() const {
     if (NewUnit)

diff  --git a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
index 0524d666810c..f1d255128187 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -313,10 +313,8 @@ unsigned DIE::computeOffsetsAndAbbrevs(const AsmPrinter *AP,
 //===----------------------------------------------------------------------===//
 // DIEUnit Implementation
 //===----------------------------------------------------------------------===//
-DIEUnit::DIEUnit(uint16_t V, uint8_t A, dwarf::Tag UnitTag)
-    : Die(UnitTag), Section(nullptr), Offset(0), Length(0), Version(V),
-      AddrSize(A)
-{
+DIEUnit::DIEUnit(dwarf::Tag UnitTag)
+    : Die(UnitTag), Section(nullptr), Offset(0) {
   Die.Owner = this;
   assert((UnitTag == dwarf::DW_TAG_compile_unit ||
           UnitTag == dwarf::DW_TAG_skeleton_unit ||

diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 2b45e50869ed..3dfd57c82f89 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -90,9 +90,8 @@ bool DIEDwarfExpression::isFrameRegister(const TargetRegisterInfo &TRI,
 
 DwarfUnit::DwarfUnit(dwarf::Tag UnitTag, const DICompileUnit *Node,
                      AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU)
-    : DIEUnit(A->getDwarfVersion(), A->MAI->getCodePointerSize(), UnitTag),
-      CUNode(Node), Asm(A), DD(DW), DU(DWU), IndexTyDie(nullptr) {
-}
+    : DIEUnit(UnitTag), CUNode(Node), Asm(A), DD(DW), DU(DWU),
+      IndexTyDie(nullptr) {}
 
 DwarfTypeUnit::DwarfTypeUnit(DwarfCompileUnit &CU, AsmPrinter *A,
                              DwarfDebug *DW, DwarfFile *DWU,

diff  --git a/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.h b/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.h
index 9ba8eab1a15b..e55dc0730180 100644
--- a/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.h
+++ b/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.h
@@ -149,18 +149,21 @@ class DIE {
 class CompileUnit {
   Generator &DG;
   BasicDIEUnit DU;
+  uint64_t Length; /// The length in bytes of all of the DIEs in this unit.
+  const uint16_t Version; /// The Dwarf version number for this unit.
+  const uint8_t AddrSize; /// The size in bytes of an address for this unit.
 
 public:
   CompileUnit(Generator &D, uint16_t V, uint8_t A)
-      : DG(D), DU(V, A, dwarf::DW_TAG_compile_unit) {}
+      : DG(D), DU(dwarf::DW_TAG_compile_unit), Version(V), AddrSize(A) {}
   DIE getUnitDIE();
   Generator &getGenerator() { return DG; }
   uint64_t getOffset() const { return DU.getDebugSectionOffset(); }
-  uint64_t getLength() const { return DU.getLength(); }
-  uint16_t getVersion() const { return DU.getDwarfVersion(); }
-  uint16_t getAddressSize() const { return DU.getAddressSize(); }
+  uint64_t getLength() const { return Length; }
+  uint16_t getVersion() const { return Version; }
+  uint16_t getAddressSize() const { return AddrSize; }
   void setOffset(uint64_t Offset) { DU.setDebugSectionOffset(Offset); }
-  void setLength(uint64_t Length) { DU.setLength(Length); }
+  void setLength(uint64_t L) { Length = L; }
 };
 
 /// A DWARF line unit-like class used to generate DWARF line units.


        


More information about the llvm-commits mailing list