[llvm] r225646 - IR: Make temporary nodes distinct
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Jan 12 10:41:26 PST 2015
Author: dexonsmith
Date: Mon Jan 12 12:41:26 2015
New Revision: 225646
URL: http://llvm.org/viewvc/llvm-project?rev=225646&view=rev
Log:
IR: Make temporary nodes distinct
Change the return of `MDNode::isDistinct()` for `MDNode::getTemporary()`
to `true`. They aren't uniqued.
Modified:
llvm/trunk/include/llvm/IR/Metadata.h
llvm/trunk/unittests/IR/MetadataTest.cpp
Modified: llvm/trunk/include/llvm/IR/Metadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Metadata.h?rev=225646&r1=225645&r2=225646&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Metadata.h (original)
+++ llvm/trunk/include/llvm/IR/Metadata.h Mon Jan 12 12:41:26 2015
@@ -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<MDNodeFwdDecl>(this);
+ }
protected:
/// \brief Set an operand.
Modified: llvm/trunk/unittests/IR/MetadataTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/MetadataTest.cpp?rev=225646&r1=225645&r2=225646&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/MetadataTest.cpp (original)
+++ llvm/trunk/unittests/IR/MetadataTest.cpp Mon Jan 12 12:41:26 2015
@@ -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);
More information about the llvm-commits
mailing list