summaryrefslogtreecommitdiff
path: root/unittests/Transforms/Utils/ValueMapperTest.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-12-30 11:46:15 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-12-30 11:46:15 +0000
commitdd58ef019b700900793a1eb48b52123db01b654e (patch)
treefcfbb4df56a744f4ddc6122c50521dd3f1c5e196 /unittests/Transforms/Utils/ValueMapperTest.cpp
parent2fe5752e3a7c345cdb59e869278d36af33c13fa4 (diff)
Notes
Diffstat (limited to 'unittests/Transforms/Utils/ValueMapperTest.cpp')
-rw-r--r--unittests/Transforms/Utils/ValueMapperTest.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/unittests/Transforms/Utils/ValueMapperTest.cpp b/unittests/Transforms/Utils/ValueMapperTest.cpp
index 137a2607c848..9dbe4dbc56de 100644
--- a/unittests/Transforms/Utils/ValueMapperTest.cpp
+++ b/unittests/Transforms/Utils/ValueMapperTest.cpp
@@ -24,4 +24,35 @@ TEST(ValueMapperTest, MapMetadataUnresolved) {
EXPECT_EQ(T.get(), MapMetadata(T.get(), VM, RF_NoModuleLevelChanges));
}
+TEST(ValueMapperTest, MapMetadataDistinct) {
+ LLVMContext Context;
+ auto *D = MDTuple::getDistinct(Context, None);
+
+ {
+ // The node should be cloned.
+ ValueToValueMapTy VM;
+ EXPECT_NE(D, MapMetadata(D, VM, RF_None));
+ }
+ {
+ // The node should be moved.
+ ValueToValueMapTy VM;
+ EXPECT_EQ(D, MapMetadata(D, VM, RF_MoveDistinctMDs));
+ }
+}
+
+TEST(ValueMapperTest, MapMetadataDistinctOperands) {
+ LLVMContext Context;
+ Metadata *Old = MDTuple::getDistinct(Context, None);
+ auto *D = MDTuple::getDistinct(Context, Old);
+ ASSERT_EQ(Old, D->getOperand(0));
+
+ Metadata *New = MDTuple::getDistinct(Context, None);
+ ValueToValueMapTy VM;
+ VM.MD()[Old].reset(New);
+
+ // Make sure operands are updated.
+ EXPECT_EQ(D, MapMetadata(D, VM, RF_MoveDistinctMDs));
+ EXPECT_EQ(New, D->getOperand(0));
+}
+
}