aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-02 17:04:38 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-02 17:04:38 +0000
commitda4a56d1abf0aa34dcb721c4b2d704a7715c23c1 (patch)
tree6ec3d98e992043a6f8f2d91b7869e11082fc68d0 /llvm/unittests/Transforms/Utils/ValueMapperTest.cpp
parentddbb1cd45a51d24642788599d2e3aafaed9bba0f (diff)
downloadllvm-da4a56d1abf0aa34dcb721c4b2d704a7715c23c1.zip
llvm-da4a56d1abf0aa34dcb721c4b2d704a7715c23c1.tar.gz
llvm-da4a56d1abf0aa34dcb721c4b2d704a7715c23c1.tar.bz2
ValueMapper: Add support for seeding metadata with nullptr
Support seeding a ValueMap with nullptr for Metadata entries, a situation I didn't consider in the Metadata/Value split. I added a ValueMapper::getMappedMD accessor that returns an Optional<Metadata*> with the mapped (possibly null) metadata. IRMover needs to use this to avoid modifying the map when it's checking for unneeded subprograms. I updated a call from bugpoint since I find the new code clearer. llvm-svn: 265228
Diffstat (limited to 'llvm/unittests/Transforms/Utils/ValueMapperTest.cpp')
-rw-r--r--llvm/unittests/Transforms/Utils/ValueMapperTest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp b/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp
index 6141c41..3c7ef1b 100644
--- a/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp
+++ b/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp
@@ -55,4 +55,30 @@ TEST(ValueMapperTest, MapMetadataDistinctOperands) {
EXPECT_EQ(New, D->getOperand(0));
}
+TEST(ValueMapperTest, MapMetadataSeeded) {
+ LLVMContext Context;
+ auto *D = MDTuple::getDistinct(Context, None);
+
+ // The node should be moved.
+ ValueToValueMapTy VM;
+ EXPECT_EQ(None, VM.getMappedMD(D));
+
+ VM.MD().insert(std::make_pair(D, TrackingMDRef(D)));
+ EXPECT_EQ(D, *VM.getMappedMD(D));
+ EXPECT_EQ(D, MapMetadata(D, VM, RF_None));
+}
+
+TEST(ValueMapperTest, MapMetadataSeededWithNull) {
+ LLVMContext Context;
+ auto *D = MDTuple::getDistinct(Context, None);
+
+ // The node should be moved.
+ ValueToValueMapTy VM;
+ EXPECT_EQ(None, VM.getMappedMD(D));
+
+ VM.MD().insert(std::make_pair(D, TrackingMDRef()));
+ EXPECT_EQ(nullptr, *VM.getMappedMD(D));
+ EXPECT_EQ(nullptr, MapMetadata(D, VM, RF_None));
+}
+
} // end namespace