[llvm] r235331 - DebugInfo: Remove DIType

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Apr 20 11:52:07 PDT 2015


Author: dexonsmith
Date: Mon Apr 20 13:52:06 2015
New Revision: 235331

URL: http://llvm.org/viewvc/llvm-project?rev=235331&view=rev
Log:
DebugInfo: Remove DIType

This is the last major parent class, so I'll probably start deleting
classes in batches now.  Looks like many of the references to the DI*
hierarchy were updated organically along the way.

Modified:
    llvm/trunk/include/llvm/IR/DebugInfo.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
    llvm/trunk/unittests/Transforms/Utils/Cloning.cpp

Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=235331&r1=235330&r2=235331&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Mon Apr 20 13:52:06 2015
@@ -51,7 +51,6 @@ class DISubprogram;
 class DILexicalBlock;
 class DILexicalBlockFile;
 class DIVariable;
-class DIType;
 class DIObjCProperty;
 
 /// \brief Maps from type identifier to the actual MDNode.
@@ -63,7 +62,6 @@ typedef DenseMap<const MDString *, MDNod
   template <> struct simplify_type<DESC>;
 DECLARE_SIMPLIFY_DESCRIPTOR(DISubrange)
 DECLARE_SIMPLIFY_DESCRIPTOR(DIEnumerator)
-DECLARE_SIMPLIFY_DESCRIPTOR(DIType)
 DECLARE_SIMPLIFY_DESCRIPTOR(DIBasicType)
 DECLARE_SIMPLIFY_DESCRIPTOR(DIDerivedType)
 DECLARE_SIMPLIFY_DESCRIPTOR(DICompositeType)
@@ -110,17 +108,6 @@ public:
   MDEnumerator &operator*() const { return *N; }
 };
 
-class DIType {
-  MDType *N;
-
-public:
-  DIType(const MDType *N = nullptr) : N(const_cast<MDType *>(N)) {}
-
-  operator MDType *() const { return N; }
-  MDType *operator->() const { return N; }
-  MDType &operator*() const { return *N; }
-};
-
 class DIBasicType {
   MDBasicType *N;
 
@@ -128,7 +115,6 @@ public:
   DIBasicType(const MDBasicType *N = nullptr)
       : N(const_cast<MDBasicType *>(N)) {}
 
-  operator DIType() const { return N; }
   operator MDBasicType *() const { return N; }
   MDBasicType *operator->() const { return N; }
   MDBasicType &operator*() const { return *N; }
@@ -141,7 +127,6 @@ public:
   DIDerivedType(const MDDerivedTypeBase *N = nullptr)
       : N(const_cast<MDDerivedTypeBase *>(N)) {}
 
-  operator DIType() const { return N; }
   operator MDDerivedTypeBase *() const { return N; }
   MDDerivedTypeBase *operator->() const { return N; }
   MDDerivedTypeBase &operator*() const { return *N; }
@@ -154,7 +139,6 @@ public:
   DICompositeType(const MDCompositeTypeBase *N = nullptr)
       : N(const_cast<MDCompositeTypeBase *>(N)) {}
 
-  operator DIType() const { return N; }
   operator MDCompositeTypeBase *() const { return N; }
   MDCompositeTypeBase *operator->() const { return N; }
   MDCompositeTypeBase &operator*() const { return *N; }
@@ -167,7 +151,6 @@ public:
   DISubroutineType(const MDSubroutineType *N = nullptr)
       : N(const_cast<MDSubroutineType *>(N)) {}
 
-  operator DIType() const { return N; }
   operator DICompositeType() const { return N; }
   operator MDSubroutineType *() const { return N; }
   MDSubroutineType *operator->() const { return N; }
@@ -348,7 +331,6 @@ public:
   template <> struct simplify_type<DESC> : simplify_type<const DESC> {};
 SIMPLIFY_DESCRIPTOR(DISubrange)
 SIMPLIFY_DESCRIPTOR(DIEnumerator)
-SIMPLIFY_DESCRIPTOR(DIType)
 SIMPLIFY_DESCRIPTOR(DIBasicType)
 SIMPLIFY_DESCRIPTOR(DIDerivedType)
 SIMPLIFY_DESCRIPTOR(DICompositeType)

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=235331&r1=235330&r2=235331&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Apr 20 13:52:06 2015
@@ -141,7 +141,7 @@ bool DbgVariable::isBlockByrefVariable()
       ->isBlockByrefStruct();
 }
 
-DIType DbgVariable::getType() const {
+const MDType *DbgVariable::getType() const {
   MDType *Ty = Var->getType().resolve(DD->getTypeIdentifierMap());
   // FIXME: isBlockByrefVariable should be reformulated in terms of complex
   // addresses instead.
@@ -459,17 +459,15 @@ void DwarfDebug::beginModule() {
       CU.getOrCreateGlobalVariableDIE(GV);
     for (auto *SP : CUNode->getSubprograms())
       SPMap.insert(std::make_pair(SP, &CU));
-    for (DIType Ty : CUNode->getEnumTypes()) {
+    for (auto *Ty : CUNode->getEnumTypes()) {
       // The enum types array by design contains pointers to
       // MDNodes rather than DIRefs. Unique them here.
-      DIType UniqueTy = cast<MDType>(resolve(Ty->getRef()));
-      CU.getOrCreateTypeDIE(UniqueTy);
+      CU.getOrCreateTypeDIE(cast<MDType>(resolve(Ty->getRef())));
     }
-    for (DIType Ty : CUNode->getRetainedTypes()) {
+    for (auto *Ty : CUNode->getRetainedTypes()) {
       // The retained types array by design contains pointers to
       // MDNodes rather than DIRefs. Unique them here.
-      DIType UniqueTy = cast<MDType>(resolve(Ty->getRef()));
-      CU.getOrCreateTypeDIE(UniqueTy);
+      CU.getOrCreateTypeDIE(cast<MDType>(resolve(Ty->getRef())));
     }
     // Emit imported_modules last so that the relevant context is already
     // available.

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=235331&r1=235330&r2=235331&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Apr 20 13:52:06 2015
@@ -165,7 +165,7 @@ public:
     return Expr.back()->getNumElements() > 0;
   }
   bool isBlockByrefVariable() const;
-  DIType getType() const;
+  const MDType *getType() const;
 
 private:
   /// resolve - Look in the DwarfDebug map for the MDNode that

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=235331&r1=235330&r2=235331&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Mon Apr 20 13:52:06 2015
@@ -421,7 +421,7 @@ void DwarfUnit::addSourceLine(DIE &Die,
 
 /// addSourceLine - Add location information to specified debug information
 /// entry.
-void DwarfUnit::addSourceLine(DIE &Die, DIType Ty) {
+void DwarfUnit::addSourceLine(DIE &Die, const MDType *Ty) {
   assert(Ty);
 
   addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory());
@@ -519,8 +519,8 @@ bool DwarfUnit::addRegisterOffset(DIELoc
 void DwarfUnit::addBlockByrefAddress(const DbgVariable &DV, DIE &Die,
                                      dwarf::Attribute Attribute,
                                      const MachineLocation &Location) {
-  DIType Ty = DV.getType();
-  DIType TmpTy = Ty;
+  const MDType *Ty = DV.getType();
+  const MDType *TmpTy = Ty;
   uint16_t Tag = Ty->getTag();
   bool isPointer = false;
 
@@ -594,7 +594,7 @@ void DwarfUnit::addBlockByrefAddress(con
 }
 
 /// Return true if type encoding is unsigned.
-static bool isUnsignedDIType(DwarfDebug *DD, DIType Ty) {
+static bool isUnsignedDIType(DwarfDebug *DD, const MDType *Ty) {
   if (DIDerivedType DTy = dyn_cast<MDDerivedTypeBase>(Ty)) {
     dwarf::Tag T = (dwarf::Tag)Ty->getTag();
     // Encode pointer constants as unsigned bytes. This is used at least for
@@ -698,13 +698,14 @@ void DwarfUnit::addConstantFPValue(DIE &
 }
 
 /// addConstantValue - Add constant value entry in variable DIE.
-void DwarfUnit::addConstantValue(DIE &Die, const ConstantInt *CI, DIType Ty) {
+void DwarfUnit::addConstantValue(DIE &Die, const ConstantInt *CI,
+                                 const MDType *Ty) {
   addConstantValue(Die, CI->getValue(), Ty);
 }
 
 /// addConstantValue - Add constant value entry in variable DIE.
 void DwarfUnit::addConstantValue(DIE &Die, const MachineOperand &MO,
-                                 DIType Ty) {
+                                 const MDType *Ty) {
   assert(MO.isImm() && "Invalid machine operand!");
 
   addConstantValue(Die, isUnsignedDIType(DD, Ty), MO.getImm());
@@ -717,7 +718,7 @@ void DwarfUnit::addConstantValue(DIE &Di
           Unsigned ? dwarf::DW_FORM_udata : dwarf::DW_FORM_sdata, Val);
 }
 
-void DwarfUnit::addConstantValue(DIE &Die, const APInt &Val, DIType Ty) {
+void DwarfUnit::addConstantValue(DIE &Die, const APInt &Val, const MDType *Ty) {
   addConstantValue(Die, Val, isUnsignedDIType(DD, Ty));
 }
 
@@ -801,7 +802,7 @@ DIE *DwarfUnit::createTypeDIE(DIComposit
 }
 
 /// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
-/// given DIType.
+/// given type.
 DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
   if (!TyNode)
     return nullptr;
@@ -865,7 +866,8 @@ void DwarfUnit::updateAcceleratorTables(
 }
 
 /// addType - Add a new type attribute to the specified entity.
-void DwarfUnit::addType(DIE &Entity, DIType Ty, dwarf::Attribute Attribute) {
+void DwarfUnit::addType(DIE &Entity, const MDType *Ty,
+                        dwarf::Attribute Attribute) {
   assert(Ty && "Trying to add a type that doesn't exist?");
 
   // Check for pre-existence.
@@ -952,7 +954,7 @@ void DwarfUnit::constructTypeDIE(DIE &Bu
   uint16_t Tag = Buffer.getTag();
 
   // Map to main type, void will not have a type.
-  DIType FromTy = resolve(DTy->getBaseType());
+  const MDType *FromTy = resolve(DTy->getBaseType());
   if (FromTy)
     addType(Buffer, FromTy);
 
@@ -977,7 +979,7 @@ void DwarfUnit::constructTypeDIE(DIE &Bu
 /// constructSubprogramArguments - Construct function argument DIEs.
 void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DITypeArray Args) {
   for (unsigned i = 1, N = Args.size(); i < N; ++i) {
-    DIType Ty = resolve(Args[i]);
+    const MDType *Ty = resolve(Args[i]);
     if (!Ty) {
       assert(i == N-1 && "Unspecified parameter must be the last argument");
       createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
@@ -1424,7 +1426,7 @@ void DwarfUnit::constructEnumTypeDIE(DIE
               Value);
     }
   }
-  DIType DTy = resolve(CTy->getBaseType());
+  const MDType *DTy = resolve(CTy->getBaseType());
   if (DTy) {
     addType(Buffer, DTy);
     addFlag(Buffer, dwarf::DW_AT_enum_class);
@@ -1556,7 +1558,7 @@ DIE *DwarfUnit::getOrCreateStaticMemberD
 
   DIE &StaticMemberDIE = createAndAddDIE(DT->getTag(), *ContextDIE, DT);
 
-  DIType Ty = resolve(DT->getBaseType());
+  const MDType *Ty = resolve(DT->getBaseType());
 
   addString(StaticMemberDIE, dwarf::DW_AT_name, DT->getName());
   addType(StaticMemberDIE, Ty);

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h?rev=235331&r1=235330&r2=235331&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h Mon Apr 20 13:52:06 2015
@@ -239,14 +239,14 @@ public:
   void addSourceLine(DIE &Die, DIVariable V);
   void addSourceLine(DIE &Die, DIGlobalVariable G);
   void addSourceLine(DIE &Die, DISubprogram SP);
-  void addSourceLine(DIE &Die, DIType Ty);
+  void addSourceLine(DIE &Die, const MDType *Ty);
   void addSourceLine(DIE &Die, DINameSpace NS);
   void addSourceLine(DIE &Die, DIObjCProperty Ty);
 
   /// addConstantValue - Add constant value entry in variable DIE.
-  void addConstantValue(DIE &Die, const MachineOperand &MO, DIType Ty);
-  void addConstantValue(DIE &Die, const ConstantInt *CI, DIType Ty);
-  void addConstantValue(DIE &Die, const APInt &Val, DIType Ty);
+  void addConstantValue(DIE &Die, const MachineOperand &MO, const MDType *Ty);
+  void addConstantValue(DIE &Die, const ConstantInt *CI, const MDType *Ty);
+  void addConstantValue(DIE &Die, const APInt &Val, const MDType *Ty);
   void addConstantValue(DIE &Die, const APInt &Val, bool Unsigned);
   void addConstantValue(DIE &Die, bool Unsigned, uint64_t Val);
 
@@ -284,7 +284,7 @@ public:
   /// addType - Add a new type attribute to the specified entity. This takes
   /// and attribute parameter because DW_AT_friend attributes are also
   /// type references.
-  void addType(DIE &Entity, DIType Ty,
+  void addType(DIE &Entity, const MDType *Ty,
                dwarf::Attribute Attribute = dwarf::DW_AT_type);
 
   /// getOrCreateNameSpace - Create a DIE for DINameSpace.
@@ -297,7 +297,7 @@ public:
                                  bool Minimal = false);
 
   /// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
-  /// given DIType.
+  /// given type.
   DIE *getOrCreateTypeDIE(const MDNode *N);
 
   /// getOrCreateContextDIE - Get context owner's DIE.

Modified: llvm/trunk/unittests/Transforms/Utils/Cloning.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Utils/Cloning.cpp?rev=235331&r1=235330&r2=235331&view=diff
==============================================================================
--- llvm/trunk/unittests/Transforms/Utils/Cloning.cpp (original)
+++ llvm/trunk/unittests/Transforms/Utils/Cloning.cpp Mon Apr 20 13:52:06 2015
@@ -251,8 +251,8 @@ protected:
     Instruction* Terminator = IBuilder.CreateRetVoid();
 
     // Create a local variable around the alloca
-    DIType IntType = DBuilder.createBasicType("int", 32, 0,
-        dwarf::DW_ATE_signed);
+    auto *IntType =
+        DBuilder.createBasicType("int", 32, 0, dwarf::DW_ATE_signed);
     DIExpression E = DBuilder.createExpression();
     DIVariable Variable = DBuilder.createLocalVariable(
       dwarf::DW_TAG_auto_variable, Subprogram, "x", File, 5, IntType, true);





More information about the llvm-commits mailing list