From: Duncan P. N. Exon Smith Date: Mon, 12 Jan 2015 18:41:26 +0000 (+0000) Subject: IR: Make temporary nodes distinct X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=28184c10c9a46611fcdf615d93509c864f13dfaf;p=oota-llvm.git IR: Make temporary nodes distinct Change the return of `MDNode::isDistinct()` for `MDNode::getTemporary()` to `true`. They aren't uniqued. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225646 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IR/Metadata.h b/include/llvm/IR/Metadata.h index 75c9734ea97..4d0a04ea623 100644 --- a/include/llvm/IR/Metadata.h +++ b/include/llvm/IR/Metadata.h @@ -651,7 +651,9 @@ public: /// /// Distinct nodes are not uniqued, and will not be returned by \a /// MDNode::get(). - bool isDistinct() const { return IsDistinctInContext; } + bool isDistinct() const { + return isStoredDistinctInContext() || isa(this); + } protected: /// \brief Set an operand. diff --git a/unittests/IR/MetadataTest.cpp b/unittests/IR/MetadataTest.cpp index 2dd54e785bf..a09cc9cfd7d 100644 --- a/unittests/IR/MetadataTest.cpp +++ b/unittests/IR/MetadataTest.cpp @@ -269,6 +269,12 @@ TEST_F(MDNodeTest, getDistinct) { ASSERT_EQ(Empty, MDNode::get(Context, None)); } +TEST_F(MDNodeTest, TempIsDistinct) { + MDNode *T = MDNode::getTemporary(Context, None); + EXPECT_TRUE(T->isDistinct()); + MDNode::deleteTemporary(T); +} + TEST_F(MDNodeTest, getDistinctWithUnresolvedOperands) { // temporary !{} MDNodeFwdDecl *Temp = MDNode::getTemporary(Context, None);