IR: DwarfNode => DebugNode, NFC
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 22 Jan 2015 22:47:44 +0000 (22:47 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 22 Jan 2015 22:47:44 +0000 (22:47 +0000)
These things are potentially used for non-DWARF data (see the discussion
in PR22235), so take the `Dwarf` out of the name.  Since the new name
gives fewer clues, update the doxygen to properly describe what they
are.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226874 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/Metadata.def
include/llvm/IR/Metadata.h
lib/Bitcode/Writer/BitcodeWriter.cpp
lib/IR/AsmWriter.cpp
lib/IR/LLVMContextImpl.h
lib/IR/Metadata.cpp
unittests/IR/MetadataTest.cpp

index a8cf28a95bb73b493a6c3471f58cf5b1c5964a22..a61446be2a483f7e1dd36d57610da6c52e8b6b3c 100644 (file)
@@ -49,8 +49,8 @@ HANDLE_METADATA_LEAF(LocalAsMetadata)
 HANDLE_MDNODE_BRANCH(MDNode)
 HANDLE_MDNODE_LEAF(MDTuple)
 HANDLE_MDNODE_LEAF(MDLocation)
-HANDLE_MDNODE_BRANCH(DwarfNode)
-HANDLE_MDNODE_LEAF(GenericDwarfNode)
+HANDLE_MDNODE_BRANCH(DebugNode)
+HANDLE_MDNODE_LEAF(GenericDebugNode)
 
 #undef HANDLE_METADATA
 #undef HANDLE_METADATA_LEAF
index 5a2630b64e8027e50a5bf412a8e3de6e718ceb8b..025ad7f0e52ea269e41812ef66745107edbc0fa9 100644 (file)
@@ -61,7 +61,7 @@ public:
   enum MetadataKind {
     MDTupleKind,
     MDLocationKind,
-    GenericDwarfNodeKind,
+    GenericDebugNodeKind,
     ConstantAsMetadataKind,
     LocalAsMetadataKind,
     MDStringKind
@@ -867,7 +867,7 @@ public:
   static bool classof(const Metadata *MD) {
     return MD->getMetadataID() == MDTupleKind ||
            MD->getMetadataID() == MDLocationKind ||
-           MD->getMetadataID() == GenericDwarfNodeKind;
+           MD->getMetadataID() == GenericDebugNodeKind;
   }
 
   /// \brief Check whether MDNode is a vtable access.
@@ -1025,56 +1025,60 @@ public:
   }
 };
 
-/// \brief Tagged dwarf node.
+/// \brief Tagged DWARF-like metadata node.
 ///
-/// A metadata node with a DWARF tag.
-class DwarfNode : public MDNode {
+/// A metadata node with a DWARF tag (i.e., a constant named \c DW_TAG_*,
+/// defined in llvm/Support/Dwarf.h).  Called \a DebugNode because it's
+/// potentially used for non-DWARF output.
+class DebugNode : public MDNode {
   friend class LLVMContextImpl;
   friend class MDNode;
 
 protected:
-  DwarfNode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
+  DebugNode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
             ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = None)
       : MDNode(C, ID, Storage, Ops1, Ops2) {
     assert(Tag < 1u << 16);
     SubclassData16 = Tag;
   }
-  ~DwarfNode() {}
+  ~DebugNode() {}
 
 public:
   unsigned getTag() const { return SubclassData16; }
 
   static bool classof(const Metadata *MD) {
-    return MD->getMetadataID() == GenericDwarfNodeKind;
+    return MD->getMetadataID() == GenericDebugNodeKind;
   }
 };
 
-/// \brief Generic tagged dwarf node.
+/// \brief Generic tagged DWARF-like metadata node.
 ///
-/// A generic metadata node with a DWARF tag that doesn't have special
-/// handling.
-class GenericDwarfNode : public DwarfNode {
+/// An un-specialized DWARF-like metadata node.  The first operand is a
+/// (possibly empty) null-separated \a MDString header that contains arbitrary
+/// fields.  The remaining operands are \a dwarf_operands(), and are pointers
+/// to other metadata.
+class GenericDebugNode : public DebugNode {
   friend class LLVMContextImpl;
   friend class MDNode;
 
-  GenericDwarfNode(LLVMContext &C, StorageType Storage, unsigned Hash,
+  GenericDebugNode(LLVMContext &C, StorageType Storage, unsigned Hash,
                    unsigned Tag, ArrayRef<Metadata *> Ops1,
                    ArrayRef<Metadata *> Ops2)
-      : DwarfNode(C, GenericDwarfNodeKind, Storage, Tag, Ops1, Ops2) {
+      : DebugNode(C, GenericDebugNodeKind, Storage, Tag, Ops1, Ops2) {
     setHash(Hash);
   }
-  ~GenericDwarfNode() { dropAllReferences(); }
+  ~GenericDebugNode() { dropAllReferences(); }
 
   void setHash(unsigned Hash) { SubclassData32 = Hash; }
   void recalculateHash();
 
-  static GenericDwarfNode *getImpl(LLVMContext &Context, unsigned Tag,
+  static GenericDebugNode *getImpl(LLVMContext &Context, unsigned Tag,
                                    MDString *Header,
                                    ArrayRef<Metadata *> DwarfOps,
                                    StorageType Storage,
                                    bool ShouldCreate = true);
 
-  TempGenericDwarfNode cloneImpl() const {
+  TempGenericDebugNode cloneImpl() const {
     return getTemporary(
         getContext(), getTag(), getHeader(),
         SmallVector<Metadata *, 4>(dwarf_op_begin(), dwarf_op_end()));
@@ -1083,32 +1087,32 @@ class GenericDwarfNode : public DwarfNode {
 public:
   unsigned getHash() const { return SubclassData32; }
 
-  static GenericDwarfNode *get(LLVMContext &Context,
+  static GenericDebugNode *get(LLVMContext &Context,
                                unsigned Tag,
                                MDString *Header,
                                ArrayRef<Metadata *> DwarfOps) {
     return getImpl(Context, Tag, Header, DwarfOps, Uniqued);
   }
-  static GenericDwarfNode *getIfExists(LLVMContext &Context, unsigned Tag,
+  static GenericDebugNode *getIfExists(LLVMContext &Context, unsigned Tag,
                                        MDString *Header,
                                        ArrayRef<Metadata *> DwarfOps) {
     return getImpl(Context, Tag, Header, DwarfOps, Uniqued,
                    /* ShouldCreate */ false);
   }
-  static GenericDwarfNode *getDistinct(LLVMContext &Context, unsigned Tag,
+  static GenericDebugNode *getDistinct(LLVMContext &Context, unsigned Tag,
                                        MDString *Header,
                                        ArrayRef<Metadata *> DwarfOps) {
     return getImpl(Context, Tag, Header, DwarfOps, Distinct);
   }
-  static TempGenericDwarfNode getTemporary(LLVMContext &Context, unsigned Tag,
+  static TempGenericDebugNode getTemporary(LLVMContext &Context, unsigned Tag,
                                            MDString *Header,
                                            ArrayRef<Metadata *> DwarfOps) {
-    return TempGenericDwarfNode(
+    return TempGenericDebugNode(
         getImpl(Context, Tag, Header, DwarfOps, Temporary));
   }
 
   /// \brief Return a (temporary) clone of this.
-  TempGenericDwarfNode clone() const { return cloneImpl(); }
+  TempGenericDebugNode clone() const { return cloneImpl(); }
 
   unsigned getTag() const { return SubclassData16; }
   MDString *getHeader() const { return cast_or_null<MDString>(getOperand(0)); }
@@ -1128,7 +1132,7 @@ public:
   }
 
   static bool classof(const Metadata *MD) {
-    return MD->getMetadataID() == GenericDwarfNodeKind;
+    return MD->getMetadataID() == GenericDebugNodeKind;
   }
 };
 
index 567e935cfa3f9d8c0f3bb3b32a48472b1ee44e97..118edc15ce6c906bd88c19d42355965031292a6d 100644 (file)
@@ -791,7 +791,7 @@ static void WriteMDLocation(const MDLocation *N, const ValueEnumerator &VE,
   Record.clear();
 }
 
-static void WriteGenericDwarfNode(const GenericDwarfNode *,
+static void WriteGenericDebugNode(const GenericDebugNode *,
                                   const ValueEnumerator &, BitstreamWriter &,
                                   SmallVectorImpl<uint64_t> &, unsigned) {
   llvm_unreachable("unimplemented");
@@ -843,7 +843,7 @@ static void WriteModuleMetadata(const Module *M,
   }
 
   unsigned MDTupleAbbrev = 0;
-  unsigned GenericDwarfNodeAbbrev = 0;
+  unsigned GenericDebugNodeAbbrev = 0;
   SmallVector<uint64_t, 64> Record;
   for (const Metadata *MD : MDs) {
     if (const MDNode *N = dyn_cast<MDNode>(MD)) {
index 56355cc913c09b447b7a96a8f143a8faa53a5c8f..d52ac87c983ca7d26d90125cf2a05f0c8efdb393 100644 (file)
@@ -1286,7 +1286,7 @@ raw_ostream &operator<<(raw_ostream &OS, FieldSeparator &FS) {
 }
 } // end namespace
 
-static void writeGenericDwarfNode(raw_ostream &, const GenericDwarfNode *,
+static void writeGenericDebugNode(raw_ostream &, const GenericDebugNode *,
                                   TypePrinting *, SlotTracker *,
                                   const Module *) {
   llvm_unreachable("Unimplemented write");
index 4d3fa4462a3d831fc197b035b32cfa40d82d7c48..a009262f80ebeea76c9db8fc6588750d555be860 100644 (file)
@@ -284,44 +284,44 @@ struct MDLocationInfo {
   }
 };
 
-/// \brief DenseMapInfo for GenericDwarfNode.
-struct GenericDwarfNodeInfo {
+/// \brief DenseMapInfo for GenericDebugNode.
+struct GenericDebugNodeInfo {
   struct KeyTy : MDNodeOpsKey {
     unsigned Tag;
     MDString *Header;
     KeyTy(unsigned Tag, MDString *Header, ArrayRef<Metadata *> DwarfOps)
         : MDNodeOpsKey(DwarfOps), Tag(Tag), Header(Header) {}
-    KeyTy(GenericDwarfNode *N)
+    KeyTy(GenericDebugNode *N)
         : MDNodeOpsKey(N, 1), Tag(N->getTag()), Header(N->getHeader()) {}
 
-    bool operator==(const GenericDwarfNode *RHS) const {
+    bool operator==(const GenericDebugNode *RHS) const {
       if (RHS == getEmptyKey() || RHS == getTombstoneKey())
         return false;
       return Tag == RHS->getTag() && Header == RHS->getHeader() &&
              compareOps(RHS, 1);
     }
 
-    static unsigned calculateHash(GenericDwarfNode *N) {
+    static unsigned calculateHash(GenericDebugNode *N) {
       return MDNodeOpsKey::calculateHash(N, 1);
     }
   };
-  static inline GenericDwarfNode *getEmptyKey() {
-    return DenseMapInfo<GenericDwarfNode *>::getEmptyKey();
+  static inline GenericDebugNode *getEmptyKey() {
+    return DenseMapInfo<GenericDebugNode *>::getEmptyKey();
   }
-  static inline GenericDwarfNode *getTombstoneKey() {
-    return DenseMapInfo<GenericDwarfNode *>::getTombstoneKey();
+  static inline GenericDebugNode *getTombstoneKey() {
+    return DenseMapInfo<GenericDebugNode *>::getTombstoneKey();
   }
   static unsigned getHashValue(const KeyTy &Key) {
     return hash_combine(Key.getHash(), Key.Tag, Key.Header);
   }
-  static unsigned getHashValue(const GenericDwarfNode *U) {
+  static unsigned getHashValue(const GenericDebugNode *U) {
     return hash_combine(U->getHash(), U->getTag(), U->getHeader());
   }
-  static bool isEqual(const KeyTy &LHS, const GenericDwarfNode *RHS) {
+  static bool isEqual(const KeyTy &LHS, const GenericDebugNode *RHS) {
     return LHS == RHS;
   }
-  static bool isEqual(const GenericDwarfNode *LHS,
-                      const GenericDwarfNode *RHS) {
+  static bool isEqual(const GenericDebugNode *LHS,
+                      const GenericDebugNode *RHS) {
     return LHS == RHS;
   }
 };
@@ -358,7 +358,7 @@ public:
 
   DenseSet<MDTuple *, MDTupleInfo> MDTuples;
   DenseSet<MDLocation *, MDLocationInfo> MDLocations;
-  DenseSet<GenericDwarfNode *, GenericDwarfNodeInfo> GenericDwarfNodes;
+  DenseSet<GenericDebugNode *, GenericDebugNodeInfo> GenericDebugNodes;
 
   // MDNodes may be uniqued or not uniqued.  When they're not uniqued, they
   // aren't in the MDNodeSet, but they're still shared between objects, so no
index fac9268f786a13f501c0edeef26d75f24c3bf42e..e55d287e63a047007cd7e31b8aa4decf107923c5 100644 (file)
@@ -541,8 +541,8 @@ void MDTuple::recalculateHash() {
   setHash(MDTupleInfo::KeyTy::calculateHash(this));
 }
 
-void GenericDwarfNode::recalculateHash() {
-  setHash(GenericDwarfNodeInfo::KeyTy::calculateHash(this));
+void GenericDebugNode::recalculateHash() {
+  setHash(GenericDebugNodeInfo::KeyTy::calculateHash(this));
 }
 
 void MDNode::dropAllReferences() {
@@ -759,7 +759,7 @@ MDLocation *MDLocation::getImpl(LLVMContext &Context, unsigned Line,
                    Storage, Context.pImpl->MDLocations);
 }
 
-GenericDwarfNode *GenericDwarfNode::getImpl(LLVMContext &Context, unsigned Tag,
+GenericDebugNode *GenericDebugNode::getImpl(LLVMContext &Context, unsigned Tag,
                                             MDString *Header,
                                             ArrayRef<Metadata *> DwarfOps,
                                             StorageType Storage,
@@ -770,8 +770,8 @@ GenericDwarfNode *GenericDwarfNode::getImpl(LLVMContext &Context, unsigned Tag,
 
   unsigned Hash = 0;
   if (Storage == Uniqued) {
-    GenericDwarfNodeInfo::KeyTy Key(Tag, Header, DwarfOps);
-    if (auto *N = getUniqued(Context.pImpl->GenericDwarfNodes, Key))
+    GenericDebugNodeInfo::KeyTy Key(Tag, Header, DwarfOps);
+    if (auto *N = getUniqued(Context.pImpl->GenericDebugNodes, Key))
       return N;
     if (!ShouldCreate)
       return nullptr;
@@ -781,9 +781,9 @@ GenericDwarfNode *GenericDwarfNode::getImpl(LLVMContext &Context, unsigned Tag,
   }
 
   Metadata *PreOps[] = {Header};
-  return storeImpl(new (DwarfOps.size() + 1) GenericDwarfNode(
+  return storeImpl(new (DwarfOps.size() + 1) GenericDebugNode(
                        Context, Storage, Hash, Tag, PreOps, DwarfOps),
-                   Storage, Context.pImpl->GenericDwarfNodes);
+                   Storage, Context.pImpl->GenericDebugNodes);
 }
 
 void MDNode::deleteTemporary(MDNode *N) {
index b2205776f6420c870a22c9f33525d2104b1e81f3..39692d6945cd895bdec41de7661c535a28e47a1f 100644 (file)
@@ -572,13 +572,13 @@ TEST_F(MDLocationTest, getTemporary) {
   EXPECT_FALSE(L->isResolved());
 }
 
-typedef MetadataTest GenericDwarfNodeTest;
+typedef MetadataTest GenericDebugNodeTest;
 
-TEST_F(GenericDwarfNodeTest, get) {
+TEST_F(GenericDebugNodeTest, get) {
   auto *Header = MDString::get(Context, "header");
   auto *Empty = MDNode::get(Context, None);
   Metadata *Ops1[] = {Empty};
-  auto *N = GenericDwarfNode::get(Context, 15, Header, Ops1);
+  auto *N = GenericDebugNode::get(Context, 15, Header, Ops1);
   EXPECT_EQ(15u, N->getTag());
   EXPECT_EQ(2u, N->getNumOperands());
   EXPECT_EQ(Header, N->getHeader());
@@ -588,7 +588,7 @@ TEST_F(GenericDwarfNodeTest, get) {
   EXPECT_EQ(Empty, N->getOperand(1));
   ASSERT_TRUE(N->isUniqued());
 
-  EXPECT_EQ(N, GenericDwarfNode::get(Context, 15, Header, Ops1));
+  EXPECT_EQ(N, GenericDebugNode::get(Context, 15, Header, Ops1));
 
   N->replaceOperandWith(1, nullptr);
   EXPECT_EQ(15u, N->getTag());
@@ -597,21 +597,21 @@ TEST_F(GenericDwarfNodeTest, get) {
   ASSERT_TRUE(N->isUniqued());
 
   Metadata *Ops2[] = {nullptr};
-  EXPECT_EQ(N, GenericDwarfNode::get(Context, 15, Header, Ops2));
+  EXPECT_EQ(N, GenericDebugNode::get(Context, 15, Header, Ops2));
 
   N->replaceDwarfOperandWith(0, Empty);
   EXPECT_EQ(15u, N->getTag());
   EXPECT_EQ(Header, N->getHeader());
   EXPECT_EQ(Empty, N->getDwarfOperand(0));
   ASSERT_TRUE(N->isUniqued());
-  EXPECT_EQ(N, GenericDwarfNode::get(Context, 15, Header, Ops1));
+  EXPECT_EQ(N, GenericDebugNode::get(Context, 15, Header, Ops1));
 }
 
-TEST_F(GenericDwarfNodeTest, getEmptyHeader) {
+TEST_F(GenericDebugNodeTest, getEmptyHeader) {
   // Canonicalize !"" to null.
   auto *Header = MDString::get(Context, "");
   EXPECT_NE(nullptr, Header);
-  auto *N = GenericDwarfNode::get(Context, 15, Header, None);
+  auto *N = GenericDebugNode::get(Context, 15, Header, None);
   EXPECT_EQ(nullptr, N->getHeader());
 }