diff options
author | Devang Patel <dpatel@apple.com> | 2010-06-22 06:14:09 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2010-06-22 06:14:09 +0000 |
commit | e4acff8720b0a92d93613fef1fb47ed701ba71c5 (patch) | |
tree | 27e4e4977843827046b3bf8412c63ffcb2cb9744 /lib/Transforms/Utils/ValueMapper.cpp | |
parent | 52e0612f7da7c711a94e0ea130b7205c6a6e6d63 (diff) |
Revert 106528. It is causing self host failures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106529 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/ValueMapper.cpp')
-rw-r--r-- | lib/Transforms/Utils/ValueMapper.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp index 16ab91000d..87ce631ca6 100644 --- a/lib/Transforms/Utils/ValueMapper.cpp +++ b/lib/Transforms/Utils/ValueMapper.cpp @@ -21,15 +21,17 @@ using namespace llvm; Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM) { - ValueToValueMapTy::iterator VMI = VM.find(V); - if (VMI != VM.end()) - return VMI->second; + Value *&VMSlot = VM[V]; + if (VMSlot) return VMSlot; // Does it exist in the map yet? + // 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<GlobalValue>(V) || isa<InlineAsm>(V) || isa<MDString>(V) || (isa<MDNode>(V) && !cast<MDNode>(V)->isFunctionLocal())) - return VM[V] = const_cast<Value*>(V); + return VMSlot = const_cast<Value*>(V); if (const MDNode *MD = dyn_cast<MDNode>(V)) { SmallVector<Value*, 4> Elts; @@ -44,7 +46,7 @@ Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM) { if (isa<ConstantInt>(C) || isa<ConstantFP>(C) || isa<ConstantPointerNull>(C) || isa<ConstantAggregateZero>(C) || isa<UndefValue>(C) || isa<MDString>(C)) - return VM[V] = C; // Primitive constants map directly + return VMSlot = C; // Primitive constants map directly if (ConstantArray *CA = dyn_cast<ConstantArray>(C)) { for (User::op_iterator b = CA->op_begin(), i = b, e = CA->op_end(); |