summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5f50874)
raw | patch | inline | side by side (parent: 5f50874)
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | |
Mon, 19 Jan 2015 18:45:35 +0000 (18:45 +0000) | ||
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | |
Mon, 19 Jan 2015 18:45:35 +0000 (18:45 +0000) |
Change `MDNode::isDistinct()` to only apply to 'distinct' nodes (not
temporaries), and introduce `MDNode::isUniqued()` and
`MDNode::isTemporary()` for the other two possibilities.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226482 91177308-0d34-0410-b5e6-96231b3b80d8
temporaries), and introduce `MDNode::isUniqued()` and
`MDNode::isTemporary()` for the other two possibilities.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226482 91177308-0d34-0410-b5e6-96231b3b80d8
index 1238bd012ac290ba638160ebdd44ee79d168430d..2b10022f256e5db6c92b38b49bb1867425d98a4c 100644 (file)
/// \brief Check if node is fully resolved.
bool isResolved() const;
- /// \brief Check if node is distinct.
- ///
- /// Distinct nodes are not uniqued, and will not be returned by \a
- /// MDNode::get().
- bool isDistinct() const {
- return isStoredDistinctInContext() || isa<MDNodeFwdDecl>(this);
- }
+ bool isUniqued() const { return Storage == Uniqued; }
+ bool isDistinct() const { return Storage == Distinct; }
+ bool isTemporary() const { return Storage == Temporary; }
protected:
/// \brief Set an operand.
diff --git a/lib/IR/Metadata.cpp b/lib/IR/Metadata.cpp
index 714b17e974e189f046c349d6daace0cc01312bc1..93778c2ca54729bfa550d13b88c6dc45b2f437ed 100644 (file)
--- a/lib/IR/Metadata.cpp
+++ b/lib/IR/Metadata.cpp
if (getOperand(I) == New)
return;
- if (isDistinct()) {
+ if (!isUniqued()) {
setOperand(I, New);
return;
}
index 477fba42412e407183eddaec0401d4fe129e7f07..5d89858e527849002d2b7bb2af08e0584d815e38 100644 (file)
ValueToValueMapTy &VM, RemapFlags Flags,
ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
- assert(!Node->isDistinct() && "Expected uniqued node");
+ assert(Node->isUniqued() && "Expected uniqued node");
// Create a dummy node in case we have a metadata cycle.
MDNodeFwdDecl *Dummy = MDNode::getTemporary(Node->getContext(), None);
index 83fd0c164f6a8ed274e4dec1a8d213d34ea125a5..930bebfef0aed3ad0567796d96cde3eb3ba5bddb 100644 (file)
ASSERT_EQ(Empty, MDNode::get(Context, None));
}
-TEST_F(MDNodeTest, TempIsDistinct) {
- MDNode *T = MDNode::getTemporary(Context, None);
- EXPECT_TRUE(T->isDistinct());
+TEST_F(MDNodeTest, isUniqued) {
+ MDNode *U = MDTuple::get(Context, None);
+ MDNode *D = MDTuple::getDistinct(Context, None);
+ MDNode *T = MDTuple::getTemporary(Context, None);
+ EXPECT_TRUE(U->isUniqued());
+ EXPECT_FALSE(D->isUniqued());
+ EXPECT_FALSE(T->isUniqued());
+ MDNode::deleteTemporary(T);
+}
+
+TEST_F(MDNodeTest, isDistinct) {
+ MDNode *U = MDTuple::get(Context, None);
+ MDNode *D = MDTuple::getDistinct(Context, None);
+ MDNode *T = MDTuple::getTemporary(Context, None);
+ EXPECT_FALSE(U->isDistinct());
+ EXPECT_TRUE(D->isDistinct());
+ EXPECT_FALSE(T->isDistinct());
+ MDNode::deleteTemporary(T);
+}
+
+TEST_F(MDNodeTest, isTemporary) {
+ MDNode *U = MDTuple::get(Context, None);
+ MDNode *D = MDTuple::getDistinct(Context, None);
+ MDNode *T = MDTuple::getTemporary(Context, None);
+ EXPECT_FALSE(U->isTemporary());
+ EXPECT_FALSE(D->isTemporary());
+ EXPECT_TRUE(T->isTemporary());
MDNode::deleteTemporary(T);
}