summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/ValueMapper.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/lib/Transforms/Utils/ValueMapper.cpp
parentddbb1cd45a51d24642788599d2e3aafaed9bba0f (diff)
downloadbcm5719-llvm-da4a56d1abf0aa34dcb721c4b2d704a7715c23c1.tar.gz
bcm5719-llvm-da4a56d1abf0aa34dcb721c4b2d704a7715c23c1.zip
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/lib/Transforms/Utils/ValueMapper.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/ValueMapper.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index b658ffba0c2..a72c456ef0f 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -305,8 +305,8 @@ static Metadata *MapMetadataImpl(const Metadata *MD,
ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
// If the value already exists in the map, use it.
- if (Metadata *NewMD = VM.MD().lookup(MD).get())
- return NewMD;
+ if (Optional<Metadata *> NewMD = VM.getMappedMD(MD))
+ return *NewMD;
if (isa<MDString>(MD))
return mapToSelf(VM, MD);
@@ -380,8 +380,8 @@ Metadata *llvm::MapMetadata(const Metadata *MD, ValueToValueMapTy &VM,
MDNode *llvm::MapMetadata(const MDNode *MD, ValueToValueMapTy &VM,
RemapFlags Flags, ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
- return cast<MDNode>(MapMetadata(static_cast<const Metadata *>(MD), VM, Flags,
- TypeMapper, Materializer));
+ return cast_or_null<MDNode>(MapMetadata(static_cast<const Metadata *>(MD), VM,
+ Flags, TypeMapper, Materializer));
}
/// RemapInstruction - Convert the instruction operands from referencing the
OpenPOWER on IntegriCloud