diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp index 87ce631ca62..16ab91000db 100644 --- a/lib/Transforms/Utils/ValueMapper.cpp +++ b/lib/Transforms/Utils/ValueMapper.cpp @@ -21,17 +21,15 @@ using namespace llvm; Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM) { - Value *&VMSlot = VM[V]; - if (VMSlot) return VMSlot; // Does it exist in the map yet? + ValueToValueMapTy::iterator VMI = VM.find(V); + if (VMI != VM.end()) + return VMI->second; - // NOTE: VMSlot can be invalidated by any reference to VM, which can grow the - // DenseMap. This includes any recursive calls to MapValue. - // Global values and non-function-local metadata do not need to be seeded into // the ValueMap if they are using the identity mapping. if (isa(V) || isa(V) || isa(V) || (isa(V) && !cast(V)->isFunctionLocal())) - return VMSlot = const_cast(V); + return VM[V] = const_cast(V); if (const MDNode *MD = dyn_cast(V)) { SmallVector Elts; @@ -46,7 +44,7 @@ Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM) { if (isa(C) || isa(C) || isa(C) || isa(C) || isa(C) || isa(C)) - return VMSlot = C; // Primitive constants map directly + return VM[V] = C; // Primitive constants map directly if (ConstantArray *CA = dyn_cast(C)) { for (User::op_iterator b = CA->op_begin(), i = b, e = CA->op_end();