diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-08 18:47:02 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-08 18:47:02 +0000 |
| commit | e05ff7c1a787cf2bf85e4c73947eea5df34ed8c3 (patch) | |
| tree | e052bd57ae1ffe9c5fb518f779b78b9b87e67e1c /llvm/unittests/Transforms/Utils/ValueMapperTest.cpp | |
| parent | 8caf33c4834f37d8788361dafef1ce0fe6426666 (diff) | |
| download | llvm-e05ff7c1a787cf2bf85e4c73947eea5df34ed8c3.zip llvm-e05ff7c1a787cf2bf85e4c73947eea5df34ed8c3.tar.gz llvm-e05ff7c1a787cf2bf85e4c73947eea5df34ed8c3.tar.bz2 | |
ValueMapper: Stop memoizing MDStrings
Stop adding MDString to the Metadata section of the ValueMap in
MapMetadata. It blows up the size of the map for no benefit, since we
can always return quickly anyway.
There is a potential follow-up that I don't think I'll push on right
away, but maybe someone else is interested: stop checking for a
pre-mapped MDString, and move the `isa<MDString>()` checks in
Mapper::mapSimpleMetadata and MDNodeMapper::getMappedOp in front of the
`VM.getMappedMD()` calls. While this would preclude explicitly
remapping MDStrings it would probably be a little faster.
llvm-svn: 265827
Diffstat (limited to 'llvm/unittests/Transforms/Utils/ValueMapperTest.cpp')
| -rw-r--r-- | llvm/unittests/Transforms/Utils/ValueMapperTest.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp b/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp index ecaea46..3bccd50 100644 --- a/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp +++ b/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp @@ -140,6 +140,21 @@ TEST(ValueMapperTest, MapMetadataNullMapGlobalWithIgnoreMissingLocals) { EXPECT_EQ(nullptr, MapValue(F.get(), VM, Flags)); } +TEST(ValueMapperTest, MapMetadataMDString) { + LLVMContext C; + auto *S1 = MDString::get(C, "S1"); + ValueToValueMapTy VM; + + // Make sure S1 maps to itself, but isn't memoized. + EXPECT_EQ(S1, MapMetadata(S1, VM)); + EXPECT_EQ(None, VM.getMappedMD(S1)); + + // We still expect VM.MD() to be respected. + auto *S2 = MDString::get(C, "S2"); + VM.MD()[S1].reset(S2); + EXPECT_EQ(S2, MapMetadata(S1, VM)); +} + TEST(ValueMapperTest, MapMetadataConstantAsMetadata) { LLVMContext C; FunctionType *FTy = |
