1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

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.

llvm-svn: 226874
This commit is contained in:
Duncan P. N. Exon Smith 2015-01-22 22:47:44 +00:00
parent 46d1b2f8de
commit 249c4d64a9
7 changed files with 62 additions and 58 deletions

View 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

View 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;
}
};

View 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)) {

View 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");

View 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

View 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) {

View 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());
}