summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/ValueMapper.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2010-06-22 05:16:56 +0000
committerDevang Patel <dpatel@apple.com>2010-06-22 05:16:56 +0000
commitb195eb4acff24bddeaa194509f7c36e1ea5e4bec (patch)
treecdef15664cc5df93840e9ba9df4379de44e151bc /llvm/lib/Transforms/Utils/ValueMapper.cpp
parentef4a2a2b546279d53790013f9bfd51064fe26c54 (diff)
downloadbcm5719-llvm-b195eb4acff24bddeaa194509f7c36e1ea5e4bec.tar.gz
bcm5719-llvm-b195eb4acff24bddeaa194509f7c36e1ea5e4bec.zip
Do not rely on DenseMap slot which can be easily invalidated when DenseMap grows.
llvm-svn: 106528
Diffstat (limited to 'llvm/lib/Transforms/Utils/ValueMapper.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/ValueMapper.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index 87ce631ca62..16ab91000db 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/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<GlobalValue>(V) || isa<InlineAsm>(V) || isa<MDString>(V) ||
(isa<MDNode>(V) && !cast<MDNode>(V)->isFunctionLocal()))
- return VMSlot = const_cast<Value*>(V);
+ return VM[V] = const_cast<Value*>(V);
if (const MDNode *MD = dyn_cast<MDNode>(V)) {
SmallVector<Value*, 4> Elts;
@@ -46,7 +44,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 VMSlot = C; // Primitive constants map directly
+ return VM[V] = 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();
OpenPOWER on IntegriCloud