[llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Feb 27 14:32:18 PST 2005



Changes in directory llvm-poolalloc/lib/PoolAllocate:

TransformFunctionBody.cpp updated: 1.36 -> 1.37
---
Log message:

Make sure to keep the NewToOldValueMap up-to-date, even for non-pointer 
values!  This fixes the horrible dangling pointer problems that I was
hitting, and allows pointer compression to successfully transform 
perimeter (hopefully it will even run) :)


---
Diffs of the changes:  (+7 -17)

 TransformFunctionBody.cpp |   24 +++++++-----------------
 1 files changed, 7 insertions(+), 17 deletions(-)


Index: llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp
diff -u llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.36 llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.37
--- llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.36	Sun Feb 13 15:24:43 2005
+++ llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp	Sun Feb 27 16:32:04 2005
@@ -75,7 +75,7 @@
     Instruction *TransformAllocationInstr(Instruction *I, Value *Size);
     Instruction *InsertPoolFreeInstr(Value *V, Instruction *Where);
 
-    void UpdateNewToOldValueMap(Value *OldVal, Value *NewV1, Value *NewV2) {
+    void UpdateNewToOldValueMap(Value *OldVal, Value *NewV1, Value *NewV2 = 0) {
       std::map<Value*, const Value*>::iterator I =
         FI.NewToOldValueMap.find(OldVal);
       assert(I != FI.NewToOldValueMap.end() && "OldVal not found in clone?");
@@ -563,26 +563,16 @@
     if (CII != SM.end()) {
       SM[NewCall] = CII->second;
       SM.erase(CII);                     // Destroy the CallInst
-    } else { 
-      // Otherwise update the NewToOldValueMap with the new CI return value
-      if (DS::isPointerType(TheCall->getType())) {
-        std::map<Value*,const Value*>::iterator CII = 
-          FI.NewToOldValueMap.find(TheCall);
-        assert(CII != FI.NewToOldValueMap.end() && "CI not found in clone?");
-        FI.NewToOldValueMap.insert(std::make_pair(NewCall, CII->second));
-        FI.NewToOldValueMap.erase(CII);
-      }
+    } else if (!FI.NewToOldValueMap.empty()) {
+      // Otherwise, if this is a clone, update the NewToOldValueMap with the new
+      // CI return value.
+      UpdateNewToOldValueMap(TheCall, NewCall);
     }
   } else if (!FI.NewToOldValueMap.empty()) {
-    std::map<Value*,const Value*>::iterator II =
-      FI.NewToOldValueMap.find(TheCall);
-    assert(II != FI.NewToOldValueMap.end() && 
-           "CI not found in clone?");
-    FI.NewToOldValueMap.insert(std::make_pair(NewCall, II->second));
-    FI.NewToOldValueMap.erase(II);
+    UpdateNewToOldValueMap(TheCall, NewCall);
   }
 
-  TheCall->getParent()->getInstList().erase(TheCall);
+  TheCall->eraseFromParent();
   visitInstruction(*NewCall);
 }
 






More information about the llvm-commits mailing list