Author: resistor Date: Sun Feb 3 22:53:00 2008 New Revision: 46694 URL: http://llvm.org/viewvc/llvm-project?rev=46694&view=rev Log: Be more precise when eliminating pointers bue to memcpy's. This allows more stores to be deleted in some cases.
Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=46694&r1=46693&r2=46694&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Sun Feb 3 22:53:00 2008 @@ -52,7 +52,7 @@ Instruction* dependency, SetVector<Instruction*>& possiblyDead); bool handleEndBlock(BasicBlock& BB, SetVector<Instruction*>& possiblyDead); - bool RemoveUndeadPointers(Value* pointer, + bool RemoveUndeadPointers(Value* pointer, uint64_t killPointerSize, BasicBlock::iterator& BBI, SmallPtrSet<Value*, 64>& deadPointers, SetVector<Instruction*>& possiblyDead); @@ -322,6 +322,7 @@ } Value* killPointer = 0; + uint64_t killPointerSize = ~0UL; // If we encounter a use of the pointer, it is no longer considered dead if (LoadInst* L = dyn_cast<LoadInst>(BBI)) { @@ -346,6 +347,11 @@ killPointer = L->getPointerOperand(); } else if (VAArgInst* V = dyn_cast<VAArgInst>(BBI)) { killPointer = V->getOperand(0); + } else if (isa<MemCpyInst>(BBI) && + isa<ConstantInt>(cast<MemCpyInst>(BBI)->getLength())) { + killPointer = cast<MemCpyInst>(BBI)->getSource(); + killPointerSize = cast<ConstantInt>( + cast<MemCpyInst>(BBI)->getLength())->getZExtValue(); } else if (AllocaInst* A = dyn_cast<AllocaInst>(BBI)) { deadPointers.erase(A); @@ -444,7 +450,7 @@ TranslatePointerBitCasts(killPointer); // Deal with undead pointers - MadeChange |= RemoveUndeadPointers(killPointer, BBI, + MadeChange |= RemoveUndeadPointers(killPointer, killPointerSize, BBI, deadPointers, possiblyDead); } @@ -453,7 +459,7 @@ /// RemoveUndeadPointers - check for uses of a pointer that make it /// undead when scanning for dead stores to alloca's. -bool DSE::RemoveUndeadPointers(Value* killPointer, +bool DSE::RemoveUndeadPointers(Value* killPointer, uint64_t killPointerSize, BasicBlock::iterator& BBI, SmallPtrSet<Value*, 64>& deadPointers, SetVector<Instruction*>& possiblyDead) { @@ -491,7 +497,7 @@ // See if this pointer could alias it AliasAnalysis::AliasResult A = AA.alias(*I, pointerSize, - killPointer, ~0U); + killPointer, killPointerSize); // If it must-alias and a store, we can delete it if (isa<StoreInst>(BBI) && A == AliasAnalysis::MustAlias) { _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits