[llvm] r226874 - IR: DwarfNode => DebugNode, NFC
Duncan P. N. Exon Smith
dexonsmith at apple.com
Thu Jan 22 14:47:44 PST 2015
Author: dexonsmith
Date: Thu Jan 22 16:47:44 2015
New Revision: 226874
URL: http://llvm.org/viewvc/llvm-project?rev=226874&view=rev
Log:
IR: DwarfNode => DebugNode, NFC
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.
Modified:
llvm/trunk/include/llvm/IR/Metadata.def
llvm/trunk/include/llvm/IR/Metadata.h
llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/trunk/lib/IR/AsmWriter.cpp
llvm/trunk/lib/IR/LLVMContextImpl.h
llvm/trunk/lib/IR/Metadata.cpp
llvm/trunk/unittests/IR/MetadataTest.cpp
Modified: llvm/trunk/include/llvm/IR/Metadata.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Metadata.def?rev=226874&r1=226873&r2=226874&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Metadata.def (original)
+++ llvm/trunk/include/llvm/IR/Metadata.def Thu Jan 22 16:47:44 2015
@@ -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
Modified: llvm/trunk/include/llvm/IR/Metadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Metadata.h?rev=226874&r1=226873&r2=226874&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Metadata.h (original)
+++ llvm/trunk/include/llvm/IR/Metadata.h Thu Jan 22 16:47:44 2015
@@ -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 DwarfNod
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;
}
};
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=226874&r1=226873&r2=226874&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Thu Jan 22 16:47:44 2015
@@ -791,7 +791,7 @@ static void WriteMDLocation(const MDLoca
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 Mo
}
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)) {
Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=226874&r1=226873&r2=226874&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Thu Jan 22 16:47:44 2015
@@ -1286,7 +1286,7 @@ raw_ostream &operator<<(raw_ostream &OS,
}
} // end namespace
-static void writeGenericDwarfNode(raw_ostream &, const GenericDwarfNode *,
+static void writeGenericDebugNode(raw_ostream &, const GenericDebugNode *,
TypePrinting *, SlotTracker *,
const Module *) {
llvm_unreachable("Unimplemented write");
Modified: llvm/trunk/lib/IR/LLVMContextImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContextImpl.h?rev=226874&r1=226873&r2=226874&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LLVMContextImpl.h (original)
+++ llvm/trunk/lib/IR/LLVMContextImpl.h Thu Jan 22 16:47:44 2015
@@ -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
Modified: llvm/trunk/lib/IR/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Metadata.cpp?rev=226874&r1=226873&r2=226874&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Metadata.cpp (original)
+++ llvm/trunk/lib/IR/Metadata.cpp Thu Jan 22 16:47:44 2015
@@ -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(LLVMCont
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::getI
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::getI
}
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) {
Modified: llvm/trunk/unittests/IR/MetadataTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/MetadataTest.cpp?rev=226874&r1=226873&r2=226874&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/MetadataTest.cpp (original)
+++ llvm/trunk/unittests/IR/MetadataTest.cpp Thu Jan 22 16:47:44 2015
@@ -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());
}
More information about the llvm-commits
mailing list