[llvm-commits] CVS: poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Feb 19 15:33:18 PST 2004
Changes in directory poolalloc/lib/PoolAllocate:
TransformFunctionBody.cpp updated: 1.16 -> 1.17
---
Log message:
Factor code a bit, no functionality changes
---
Diffs of the changes: (+17 -19)
Index: poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp
diff -u poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.16 poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.17
--- poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.16 Sun Feb 8 15:51:40 2004
+++ poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp Thu Feb 19 15:28:11 2004
@@ -60,6 +60,16 @@
void visitStoreInst (StoreInst &I);
private:
+ void UpdateNewToOldValueMap(Value *OldVal, Value *NewV1, Value *NewV2) {
+ std::map<Value*, const Value*>::iterator I =
+ FI.NewToOldValueMap.find(OldVal);
+ assert(I != FI.NewToOldValueMap.end() && "OldVal not found in clone?");
+ FI.NewToOldValueMap.insert(std::make_pair(NewV1, I->second));
+ if (NewV2)
+ FI.NewToOldValueMap.insert(std::make_pair(NewV2, I->second));
+ FI.NewToOldValueMap.erase(I);
+ }
+
DSNodeHandle& getDSNodeHFor(Value *V) {
if (!FI.NewToOldValueMap.empty()) {
// If the NewToOldValueMap is in effect, use it.
@@ -138,7 +148,6 @@
AddPoolUse(*V, PH, PoolUses);
-
// Cast to the appropriate type if necessary
Value *Casted = V;
if (V->getType() != MI.getType())
@@ -147,28 +156,17 @@
// Update def-use info
MI.replaceAllUsesWith(Casted);
- // Remove old malloc instruction
- MI.getParent()->getInstList().erase(&MI);
-
- DSGraph::ScalarMapTy &SM = G.getScalarMap();
- DSGraph::ScalarMapTy::iterator MII = SM.find(&MI);
-
// If we are modifying the original function, update the DSGraph...
- if (MII != SM.end()) {
- // V and Casted now point to whatever the original malloc did...
- SM[V] = MII->second;
+ if (!FI.Clone) {
+ G.getScalarMap().replaceScalar(&MI, V);
if (V != Casted)
- SM[Casted] = MII->second;
- SM.erase(MII); // The malloc is now destroyed
+ G.getScalarMap()[Casted] = G.getScalarMap()[V];
} else { // Otherwise, update the NewToOldValueMap
- std::map<Value*,const Value*>::iterator MII =
- FI.NewToOldValueMap.find(&MI);
- assert(MII != FI.NewToOldValueMap.end() && "MI not found in clone?");
- FI.NewToOldValueMap.insert(std::make_pair(V, MII->second));
- if (V != Casted)
- FI.NewToOldValueMap.insert(std::make_pair(Casted, MII->second));
- FI.NewToOldValueMap.erase(MII);
+ UpdateNewToOldValueMap(&MI, V, V != Casted ? Casted : 0);
}
+
+ // Remove old malloc instruction
+ MI.getParent()->getInstList().erase(&MI);
}
void FuncTransform::visitFreeInst(FreeInst &FrI) {
More information about the llvm-commits
mailing list