[llvm-commits] [llvm] r106529 - /llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp

Devang Patel dpatel at apple.com
Mon Jun 21 23:14:09 PDT 2010


Author: dpatel
Date: Tue Jun 22 01:14:09 2010
New Revision: 106529

URL: http://llvm.org/viewvc/llvm-project?rev=106529&view=rev
Log:
Revert 106528. It is causing self host failures.

Modified:
    llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp

Modified: llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp?rev=106529&r1=106528&r2=106529&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp Tue Jun 22 01:14:09 2010
@@ -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 @@
   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();





More information about the llvm-commits mailing list