[llvm] r235071 - DebugInfo: DIRef<> => TypedDebugNodeRef<>

Duncan P. N. Exon Smith dexonsmith at apple.com
Wed Apr 15 19:24:01 PDT 2015


Author: dexonsmith
Date: Wed Apr 15 21:24:01 2015
New Revision: 235071

URL: http://llvm.org/viewvc/llvm-project?rev=235071&view=rev
Log:
DebugInfo: DIRef<> => TypedDebugNodeRef<>

Delete `DIRef<>`, and replace the remaining uses of it with
`TypedDebugNodeRef<>`.  To minimize code churn, I've added typedefs from
`MDTypeRef` to `DITypeRef` (etc.).

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.h
    llvm/trunk/lib/IR/DebugInfo.cpp

Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=235071&r1=235070&r2=235071&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Wed Apr 15 21:24:01 2015
@@ -100,6 +100,9 @@ DECLARE_SIMPLIFY_DESCRIPTOR(DIImportedEn
 
 typedef DebugNodeArray DIArray;
 typedef MDTypeRefArray DITypeArray;
+typedef DebugNodeRef DIDescriptorRef;
+typedef MDScopeRef DIScopeRef;
+typedef MDTypeRef DITypeRef;
 
 class DISubrange {
   MDSubrange *N;
@@ -124,11 +127,6 @@ public:
   MDEnumerator &operator*() const { return *N; }
 };
 
-template <typename T> class DIRef;
-typedef DIRef<DIDescriptor> DIDescriptorRef;
-typedef DIRef<DIScope> DIScopeRef;
-typedef DIRef<DIType> DITypeRef;
-
 class DIScope {
   MDScope *N;
 
@@ -141,32 +139,6 @@ public:
   MDScope &operator*() const { return *N; }
 };
 
-/// \brief Represents reference to a DIDescriptor.
-///
-/// Abstracts over direct and identifier-based metadata references.
-template <typename T> class DIRef {
-  /// \brief Val can be either a MDNode or a MDString.
-  ///
-  /// In the latter, MDString specifies the type identifier.
-  const Metadata *Val;
-
-public:
-  template <class U>
-  DIRef(const TypedDebugNodeRef<U> &Ref,
-        typename std::enable_if<std::is_convertible<U *, T>::value>::type * =
-            nullptr)
-      : Val(Ref) {}
-
-  T resolve(const DITypeIdentifierMap &Map) const;
-  operator Metadata *() const { return const_cast<Metadata *>(Val); }
-};
-
-template <>
-DIDescriptor DIRef<DIDescriptor>::resolve(const DITypeIdentifierMap &Map) const;
-template <>
-DIScope DIRef<DIScope>::resolve(const DITypeIdentifierMap &Map) const;
-template <> DIType DIRef<DIType>::resolve(const DITypeIdentifierMap &Map) const;
-
 class DIType {
   MDType *N;
 

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=235071&r1=235070&r2=235071&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Apr 15 21:24:01 2015
@@ -129,7 +129,7 @@ bool DebugLocDwarfExpression::isFrameReg
 
 /// resolve - Look in the DwarfDebug map for the MDNode that
 /// corresponds to the reference.
-template <typename T> T DbgVariable::resolve(DIRef<T> Ref) const {
+template <typename T> T *DbgVariable::resolve(TypedDebugNodeRef<T> Ref) const {
   return DD->resolve(Ref);
 }
 

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=235071&r1=235070&r2=235071&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Apr 15 21:24:01 2015
@@ -173,7 +173,7 @@ public:
 private:
   /// resolve - Look in the DwarfDebug map for the MDNode that
   /// corresponds to the reference.
-  template <typename T> T resolve(DIRef<T> Ref) const;
+  template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const;
 };
 
 
@@ -577,9 +577,6 @@ public:
   void emitDebugLocEntryLocation(const DebugLocEntry &Entry);
 
   /// Find the MDNode for the given reference.
-  template <typename T> T resolve(DIRef<T> Ref) const {
-    return Ref.resolve(TypeIdentifierMap);
-  }
   template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const {
     return Ref.resolve(TypeIdentifierMap);
   }

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h?rev=235071&r1=235070&r2=235071&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h Wed Apr 15 21:24:01 2015
@@ -342,9 +342,6 @@ protected:
 
   /// resolve - Look in the DwarfDebug map for the MDNode that
   /// corresponds to the reference.
-  template <typename T> T resolve(DIRef<T> Ref) const {
-    return DD->resolve(Ref);
-  }
   template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const {
     return DD->resolve(Ref);
   }

Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=235071&r1=235070&r2=235071&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Wed Apr 15 21:24:01 2015
@@ -307,20 +307,6 @@ bool DebugInfoFinder::addScope(DIScope S
   return true;
 }
 
-template <>
-DIDescriptor
-DIRef<DIDescriptor>::resolve(const DITypeIdentifierMap &Map) const {
-  return DIDescriptor(DebugNodeRef(Val).resolve(Map));
-}
-template <>
-DIScope DIRef<DIScope>::resolve(const DITypeIdentifierMap &Map) const {
-  return MDScopeRef(Val).resolve(Map);
-}
-template <>
-DIType DIRef<DIType>::resolve(const DITypeIdentifierMap &Map) const {
-  return MDTypeRef(Val).resolve(Map);
-}
-
 bool llvm::stripDebugInfo(Function &F) {
   bool Changed = false;
   for (BasicBlock &BB : F) {





More information about the llvm-commits mailing list