From da4a56d1abf0aa34dcb721c4b2d704a7715c23c1 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Sat, 2 Apr 2016 17:04:38 +0000 Subject: 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 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 --- llvm/lib/Transforms/Utils/ValueMapper.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Transforms/Utils/ValueMapper.cpp') diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp index b658ffb..a72c456 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 NewMD = VM.getMappedMD(MD)) + return *NewMD; if (isa(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(MapMetadata(static_cast(MD), VM, Flags, - TypeMapper, Materializer)); + return cast_or_null(MapMetadata(static_cast(MD), VM, + Flags, TypeMapper, Materializer)); } /// RemapInstruction - Convert the instruction operands from referencing the -- cgit v1.1